Home > Back-end >  Capture images TSampleGrabber error, trouble ace to help me to check it out!! Thank you very much!
Capture images TSampleGrabber error, trouble ace to help me to check it out!! Thank you very much!

Time:10-08

Successful or more, it was in the captured image timing error invalid pointer operation, and then direct flash back program
//the time interval of capture almost 1
1 SEC


The code is as follows:
Procedure TmainForm. SampleGrabber1Buffer (Sender: TObject;
SampleTime: Double; PBuffer: Pointer; BufferLen: Integer);
Var
TmpBmp: TBitmap;
TmpBmp2: TBitmap;
JPG: TJPEGImage;
TimeStr: string;
FileName: the string;
JpgFile: TFileStream;
Dir: string;
The begin
If bmp1isLock then begin
CardTimer. Enabled:=False;//read card timer
ProgLog. ErrorLogToFile (True, 'SampleGrabber1Buffer', 'began to save the pictures! ');
Bmp1isLock:=False;
JPG:=TJPEGImage. Create;
Try
TmpBmp2:=TBitmap. Create;
If SampleGrabber1. GetBitmap (tmpBmp2, pBuffer, BufferLen) then
The begin
TimeStr:=FormatDateTime (' MM - dd yyyy - hh: MM: ss ', Now);
Cam1Bmp. Assign (tmpBmp2);//cam1Bmp cameras captured TBitmap image
Cam1Bmp. Canvas. TextOut (10, 10, timeStr);
end;
JPG. Assign (cam1Bmp);
TimeLbl. Caption:=timeStr;
Jpg.Com pressionQuality:=65;//JPG compression quality
JPG. JPEGNeeded;//compression
FileName:=getFileName () + recID;
Dir:=CapDir + + FormatDateTime 'snapshot \' (' yyyyMMdd ', Now) + '\';
If not DirectoryExists (dir) then ForceDirectories (dir);//create the images directory
If FileExists (CapDir + + fileName 'snapshot \' + 'JPG') then the fileName:='9' + fileName.//file name is
JpgFile:=TFileStream. Create (dir + fileName + 'JPG', fmCreate);//open the file flow
JpgFile. Position:=0;
JPG. SaveToStream (JpgFile);//images saved in the folder


SnapImg. Picture. Assign (JPG);//snapImg displayed image control


//call a stored procedure saved to the database
StreamPic:=TMemoryStream. Create;//create a memory stream
JPG. SaveToStream (StreamPic);
If (cardNo & lt;> ") then the begin
DbResult:=DBConnfrm addCardRecord (ADOStoredProc2, CardID, cardNo, strName, timeStr, fileName) + '#';
end;

Bmp1isLock:=False;//cam1Bmp locking sign
FREEANDNIL (StreamPic);
FREEANDNIL (JpgFile);
FREEANDNIL (JPG);
FREEANDNIL (tmpBmp2);
Except,
On E: the Exception do
The begin
ProgLog. ErrorLogToFile (True, 'getPictureClick' (' save image exception! '+ E.m essage));
If (JPG & lt;> Nil) then FREEANDNIL (JPG);
If (JpgFile & lt;> Nil) then FREEANDNIL (JpgFile);
If (tmpBmp2 & lt;> Nil) then FREEANDNIL (tmpBmp2);
If (tmpBmp & lt;> Nil) then FREEANDNIL (tmpBmp);
end;
end;
CardTimer. Enabled:=True;
end;
end;

CodePudding user response:

CodePudding user response:

No one!!!!!!!!!!

CodePudding user response:

Have no TVideoWindow preview open?
If you have, the following ways to catch the picture
Fstream:=TMemoryStream. Create;
VideoWindow. VMRGetBitmap (fstream);
Fstream. SaveToFile (FShootFile);
Fstream. Free;
  • Related