Hello to all,
I've written a class in a rest service with Delphi XE11 which grabs pictures from IP-Kameras every time we scale a truck.
I call the camera via URL and get back the image.
Problem is, it works fine a few times then it stops working. Stop's working means the LoadFromURL method gives me back a "false". I don't know what's the reason for this problem.
The TImageEnView Object will be created the first time when the method to grab the picture is called and lives as long as the service is running. I don't know if there somethings should be freed between the calls or why it works only for a few times.
Maybe someone have a idea what goes wrong here.
Any help would be helpful.
Best Regards,
Chris
Following the actual code with TImageEnView:
var
FImageView : TImageEnView;
begin
if not assigned(FImageView) then
FImageView := TImageEnView.create(NIL);
with Kamera.CameraList do
begin
for i := 0 to count-1 do
begin
sURL := copy(Kamera.CameraList[i],Pos('=',Kamera.CameraList[i]) + 1,length(Kamera.CameraList[i])-
Pos('=',Kamera.CameraList[i])+1);
bOK:= FImageView.IO.LoadFromURL(sURL);
if (bOK = true) then
begin
Log('dograb','Image of camera ' + inttostr(i+1) + ' - Download successful.');
sFilename:= CreateFileName(sWeighingNo,iPosnr,Kamera,i+1);
FImageView.IO.SaveToFileJpeg(sPath + sFilename);
// Replace Src of the images inside the template.
lstTemplate.text:= ReplaceStr(lstTemplate.Text,sBild,sFilename);
end
else
begin
Log('dograb','No image from camera ' + inttostr(i+1) + ' (IP: ' + sIP + ''').');
end;
end;
end;
// replace text in template
lstTemplate.text:= ReplaceStr(lstTemplate.Text,'Scale/WS',sScaleNr + '/' + sWeighingNo + '/' + inttostr(iPosnr));
lstTemplate.SaveToFile(sPath + 'viewpicture.html');
Log('dograb','Viewpicture.html erzeugt.');
end;
... freeing camera and list objects ...
end;