Using TvideoImage to capture image from webCam

3

I'm using the TvideoImage component to capture image through webCam , however I'm having trouble, an application has been created that allows me to take pictures of clients to register, the application was incorporated into the main system to take pictures of clients, when I open the application through the system, the first time works perfectly, but when I close and try to open again, when I click the connect button the image goes blank.

Code in event OnCreate :

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

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

Code used to connect 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 to close button:

fVideoImage.VideoStop;
bActivated := false;
imgCamera.Picture := nil;
//imgCamera.Picture.Bitmap.Assign(nil);
Close;
    
asked by anonymous 20.04.2015 / 19:51

0 answers