Page 1 of 1

WebCam example Delphi 10.2

Posted: Fri Mar 03, 2023 10:57 am
by Graw
Hi,

when I try to use the webcam example I get an error when I press camera on.
It depends on the procedure btnSnapShozClick.

The z.Free is the reason for the error.
But when I remove this line the RAM is getting higher and higher with each Snapshot.
How can I solve this issue?

Thanks.

Code: Select all

procedure TfrmMain.btnSnapShotClick(Sender: TObject);
var
  Img: TBitmap;
  z : TRVImageWrapper;
begin
  if Globalz then
    Exit;
  globalz := True;

  try
    image1.Canvas.Lock;
    z := RVCamera1.GetSnapShot;

    Img := z.Bitmap.GetBitmap;
    image1.Picture.Assign(img);
  finally
    FreeAndNil(Img);
    z.Free;
    image1.Canvas.Unlock;
  end;
  Globalz := False;
end;

Re: WebCam example Delphi 10.2

Posted: Fri Mar 03, 2023 3:31 pm
by Sergey Tkachenko
Remove the line

Code: Select all

FreeAndNil(Img);

Re: WebCam example Delphi 10.2

Posted: Mon Mar 06, 2023 7:23 am
by Graw
Great,

thanks a lot.