Using Tvideoimage to capture webcam image

Asked

Viewed 2,982 times

3

I’m using the component TvideoImage to capture image through the webcam, however I’m in trouble, was created an application that allows you to take photos of customers for registration, the application was embedded in the main system to take photos of customers, when I open the application by the system, the first time works perfectly, but when I close and try to open again, when I click on the button turn the image is blank.

Code at the event OnCreate:

fVideoImage := TVideoImage.Create;
bActivated := False;

DeviceList := TStringList.Create;
fVideoImage.GetListOfDevices(DeviceList);
cbListaCameras.Items := DeviceList;
DeviceList.Free;

Code used to turn on the camera:

procedure TFormCamera.btnLigarClick(Sender: TObject);
var
  camDevice: string;
begin
  try
     if not(bActivated)then
     begin
        camDevice := trim(cbListaCameras.Items.Strings[cbListaCameras.ItemIndex]);
        if(camDevice = '')then
        begin
           ShowMessage('Atenção, informe o dispositivo!');
           cbListaCameras.SetFocus;
           Exit;
        end;

        fVideoImage.SetDisplayCanvas(imgCamera.Canvas);
        fVideoImage.VideoStart(camDevice);
        bActivated := True;

        lblCameraStatus.Caption := 'Ligada';
        lblCameraStatus.Font.Color := clGreen;

     end else
        MessageDlg('Atenção, camera já está ligada!', mtWarning, [mbOK], 0);>>

  except
     bActivated := False;
     lblCameraStatus.Caption := 'Desligada';
     lblCameraStatus.Font.Color := clRed;
     ShowMessage('Atenção, erro ao tentar ligar a camera!');
  end;
end;

Code used on close button:

fVideoImage.VideoStop;
bActivated := false;
imgCamera.Picture := nil;
//imgCamera.Picture.Bitmap.Assign(nil);
Close;
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.