Stefan Ey
December 13, 2005, 09:11:44
Hello ,
i have written a program in delphi 5.0 and uses a firewire camera (cs8850dif). The program works normaly and i can save images. Now i use a frame grabber card (DFG/SV1) with the same program/code and when i want save the image i get the following error message:
"An option is not avaible, e.g. you called setFlipH and the VideoCaptureDevice does not supporting flipping."
When i change the "LiveCaptureContinuous" property from true to false, i can save images without error message but the "ImageAvaible"-Event will never throw so that i blind.
I have tryed the 2.0 and new 3.0 activex control, its the same behavior.
Here are my questions:
a) is it a bug of the activex control or the card driver?
b) have i make false settings?
c) gives a workaround?
Thanks
Stefan Ey
Here is the code i use to initialize the device, start the live running,
show the image on screen and snap a image to file on hard disk.
{-----------------------------------------------------------------------}
procedure TfrmMain.acInitExecute(Sender: TObject);
const
CAM_SETTINGS_FILE_NAME = 'camera.settings';
begin
if FileExists(CAM_SETTINGS_FILE_NAME) then
IcImage.LoadDeviceStateFromFile(CAM_SETTINGS_FILE_ NAME, true);
if not IcImage.DeviceValid then
IcImage.ShowDeviceSettingsDialog;
if IcImage.DeviceValid then begin
fr.Image.Width := IcImage.ImageWidth;
fr.Image.Height := IcImage.ImageHeight;
IcImage.LiveDisplay := false;
IcImage.LiveCaptureLastImage := false;
IcImage.LiveCaptureContinuous := true;
IcImage.MemoryRingBufferSize := 10;
IcImage.SaveDeviceStateToFile(CAM_SETTINGS_FILE_NA ME);
acStartLive.Enabled := true;
acStartLive.Execute;
end; //if
acInit.Enabled := not IcImage.DeviceValid;
acStartLive.Enabled := IcImage.DeviceValid and not IcImage.LiveVideoRunning;
acStopLive.Enabled := IcImage.DeviceValid and IcImage.LiveVideoRunning;
acSnap.Enabled := IcImage.DeviceValid and IcImage.LiveVideoRunning;
end;
{-----------------------------------------------------------------------}
procedure TfrmMain.IcImageImageAvailable(Sender: TObject; BufferIndex: Integer);
var
hDIB: HGLOBAL;
pPixel: PCHAR;
pDIB: PCHAR;
bitmapinfo: Windows.BITMAPINFO;
iWidth, iHeight: integer;
begin
IcImage.ImageBuffers.Item[BufferIndex].Lock();
hDIB := IcImage.ImageBuffers.Item[BufferIndex].GetDib();
pDIB := GlobalLock(hDIB);
Move(pDIB^, bitmapinfo, sizeof(Windows.BITMAPINFO));
pPixel := pDIB + sizeof(bitmapinfo) - 4;
iWidth := bitmapinfo.bmiHeader.biWidth;
iHeight := bitmapinfo.bmiHeader.biHeight;
SetStretchBltMode(fr.Image.Canvas.Handle, COLORONCOLOR);
StretchDIBits(fr.Image.Canvas.Handle,
0, 0, iWidth, iHeight, 0, iHeight, iWidth, iHeight,
pPixel, bitmapinfo, DIB_RGB_COLORS, SRCCOPY);
fr.Image.Refresh;
GlobalUnlock(hDIB);
GlobalFree(hDIB);
IcImage.ImageBuffers.Item[BufferIndex].UnLock();
end;
{-----------------------------------------------------------------------}
procedure TfrmMain.acStartLiveExecute(Sender: TObject);
begin
if IcImage.DeviceValid and not IcImage.LiveVideoRunning then begin
fr.Image.Free;
fr.Image := TImage.Create(fr);
fr.Image.parent := fr.pImage;
fr.Image.Top := 5;
fr.Image.Left := 5;
fr.Image.Width := IcImage.ImageWidth;
fr.Image.Height := IcImage.ImageHeight;
IcImage.LiveStart;
acStartLive.Enabled := not IcImage.LiveVideoRunning;
acStopLive.Enabled := IcImage.LiveVideoRunning;
acSnap.Enabled := IcImage.LiveVideoRunning;
end;
end;
{-----------------------------------------------------------------------}
procedure TfrmMain.acSnapExecute(Sender: TObject);
begin
if IcImage.DeviceValid and IcImage.LiveVideoRunning then begin
IcImage.MemorySnapImage;
IcImage.MemorySaveImage('test.bmp');
acStartLive.Enabled := IcImage.DeviceValid and not IcImage.LiveVideoRunning;
acStopLive.Enabled := IcImage.DeviceValid and IcImage.LiveVideoRunning;
acSnap.Enabled := IcImage.DeviceValid and IcImage.LiveVideoRunning;
end;
end;
i have written a program in delphi 5.0 and uses a firewire camera (cs8850dif). The program works normaly and i can save images. Now i use a frame grabber card (DFG/SV1) with the same program/code and when i want save the image i get the following error message:
"An option is not avaible, e.g. you called setFlipH and the VideoCaptureDevice does not supporting flipping."
When i change the "LiveCaptureContinuous" property from true to false, i can save images without error message but the "ImageAvaible"-Event will never throw so that i blind.
I have tryed the 2.0 and new 3.0 activex control, its the same behavior.
Here are my questions:
a) is it a bug of the activex control or the card driver?
b) have i make false settings?
c) gives a workaround?
Thanks
Stefan Ey
Here is the code i use to initialize the device, start the live running,
show the image on screen and snap a image to file on hard disk.
{-----------------------------------------------------------------------}
procedure TfrmMain.acInitExecute(Sender: TObject);
const
CAM_SETTINGS_FILE_NAME = 'camera.settings';
begin
if FileExists(CAM_SETTINGS_FILE_NAME) then
IcImage.LoadDeviceStateFromFile(CAM_SETTINGS_FILE_ NAME, true);
if not IcImage.DeviceValid then
IcImage.ShowDeviceSettingsDialog;
if IcImage.DeviceValid then begin
fr.Image.Width := IcImage.ImageWidth;
fr.Image.Height := IcImage.ImageHeight;
IcImage.LiveDisplay := false;
IcImage.LiveCaptureLastImage := false;
IcImage.LiveCaptureContinuous := true;
IcImage.MemoryRingBufferSize := 10;
IcImage.SaveDeviceStateToFile(CAM_SETTINGS_FILE_NA ME);
acStartLive.Enabled := true;
acStartLive.Execute;
end; //if
acInit.Enabled := not IcImage.DeviceValid;
acStartLive.Enabled := IcImage.DeviceValid and not IcImage.LiveVideoRunning;
acStopLive.Enabled := IcImage.DeviceValid and IcImage.LiveVideoRunning;
acSnap.Enabled := IcImage.DeviceValid and IcImage.LiveVideoRunning;
end;
{-----------------------------------------------------------------------}
procedure TfrmMain.IcImageImageAvailable(Sender: TObject; BufferIndex: Integer);
var
hDIB: HGLOBAL;
pPixel: PCHAR;
pDIB: PCHAR;
bitmapinfo: Windows.BITMAPINFO;
iWidth, iHeight: integer;
begin
IcImage.ImageBuffers.Item[BufferIndex].Lock();
hDIB := IcImage.ImageBuffers.Item[BufferIndex].GetDib();
pDIB := GlobalLock(hDIB);
Move(pDIB^, bitmapinfo, sizeof(Windows.BITMAPINFO));
pPixel := pDIB + sizeof(bitmapinfo) - 4;
iWidth := bitmapinfo.bmiHeader.biWidth;
iHeight := bitmapinfo.bmiHeader.biHeight;
SetStretchBltMode(fr.Image.Canvas.Handle, COLORONCOLOR);
StretchDIBits(fr.Image.Canvas.Handle,
0, 0, iWidth, iHeight, 0, iHeight, iWidth, iHeight,
pPixel, bitmapinfo, DIB_RGB_COLORS, SRCCOPY);
fr.Image.Refresh;
GlobalUnlock(hDIB);
GlobalFree(hDIB);
IcImage.ImageBuffers.Item[BufferIndex].UnLock();
end;
{-----------------------------------------------------------------------}
procedure TfrmMain.acStartLiveExecute(Sender: TObject);
begin
if IcImage.DeviceValid and not IcImage.LiveVideoRunning then begin
fr.Image.Free;
fr.Image := TImage.Create(fr);
fr.Image.parent := fr.pImage;
fr.Image.Top := 5;
fr.Image.Left := 5;
fr.Image.Width := IcImage.ImageWidth;
fr.Image.Height := IcImage.ImageHeight;
IcImage.LiveStart;
acStartLive.Enabled := not IcImage.LiveVideoRunning;
acStopLive.Enabled := IcImage.LiveVideoRunning;
acSnap.Enabled := IcImage.LiveVideoRunning;
end;
end;
{-----------------------------------------------------------------------}
procedure TfrmMain.acSnapExecute(Sender: TObject);
begin
if IcImage.DeviceValid and IcImage.LiveVideoRunning then begin
IcImage.MemorySnapImage;
IcImage.MemorySaveImage('test.bmp');
acStartLive.Enabled := IcImage.DeviceValid and not IcImage.LiveVideoRunning;
acStopLive.Enabled := IcImage.DeviceValid and IcImage.LiveVideoRunning;
acSnap.Enabled := IcImage.DeviceValid and IcImage.LiveVideoRunning;
end;
end;