PDA

View Full Version : 21BF04.H & DCL/RL.WI 4540 & Delphi 2006



Miller
March 29, 2009, 20:21:11
Hello.
I use the 'DFK 21BF04.H - camera' with the Lighting 'DCL/RL.WI 4540' with
ActiveX and Delphi 2006.
My problem is to assign a picture from the image buffer :question:
to a Delphi.TBitmap or TImage.

Thanks for help!

Stefan Geissler
March 30, 2009, 10:30:19
Hello,

I must surrender, I am no Delphi programmer, thus my hints may are somewhat inexact.



pPixel: ^Pixeldata;
ImageData: OleVariant;
Image1: TImage;
Color: TColor;
r,b,g: Integer;


Now you can use a loop to copy the pixels from the image buffer into the TImage:
ImageData:= ICImagingControl1.MemoryGetImageData;
pPixel:=TVarData(ImageData).Varray^.data;
{pPixel points directly to the beginning of the image pixel data }



for iY := 1 to 478 do
Begin
iX := 0;
while iX < 639 Do
Begin
color := integer(pPixel^[iY,iX]);
Image1.Canvas.Pixels[iX,479-iY] := Color;
End;
End;

Image1.refresh;


I must admit, this method is not the fastest. I guess, there are faster methods available that can use the pPixel pointer directly.

May be you can do following:


procedure TForm1.OnImageAvailable(Sender: TObject; BufferIndex: Integer);
type
Pixeldata = Array[ 0..479,0..639] of byte;
TRGB = packed record
b:byte;
g:byte;
r:byte;
a:byte;
end;

PRGB = ^TRGB;
var
CurrentBuffer: ImageBuffer;
ImageData: OleVariant;
pPixel: ^Pixeldata;
iX, iY: integer;
r,b,g: Integer;
P:PRGB;

begin
CurrentBuffer:= ICImagingControl1.ImageBuffers.Item[BufferIndex];
CurrentBuffer.Lock;
ImageData:= CurrentBuffer.GetImageData;
pPixel:=TVarData(ImageData).Varray^.data;
{pPixel points directly to the beginning of the image pixel data }

for iY := 0 to 478 do
Begin
iX := 0;
P:= PRGB(Image1.Picture.Bitmap.ScanLine[479-iY]);
while iX < 639 Do
begin
P^.a := 0;
P^.b := pPixel^[iY,iX];
P^.g := pPixel^[iY+1,iX];
P^.r := pPixel^[iY+2,iX];
Inc(iX );
Inc(P);
end;
end;
CurrentBuffer.ReleaseImageData(ImageData);
CurrentBuffer.UnLock;
Image1.refresh;
end;

This is a little bit faster, because it does direct pointer operations. I did not test this on my own, but I want to bive you an idea about how to do the job.

Miller
March 30, 2009, 22:06:07
Thank you very much for your answer.
I will try it tomorrow.

Miller
April 5, 2009, 09:52:41
:good:
Hi, here i am again with a new question and my result.

How can i get full acces to lighting 'DCL/RL.WI 4540' ?

Best regards
Miller

Quick and easy ;-)

procedure TForm2.GetBitmapClick(Sender: TObject);
type
Pixeldata = Array[ 0..479,0..639] of TRGBTriple;
var
CurrentBuffer: ImageBuffer;
ImageData: OleVariant;
pPixel: ^Pixeldata;
iX, iY, sx, sy: integer;
Ziel : ^TRGBTriple;
begin
If ICImagingControl1.LiveVideoRunning Then ICImagingControl1.MemorySnapImage;
sx := ICImagingControl1.ImageWidth;
sy := ICImagingControl1.ImageHeight;
CurrentBuffer:= ICImagingControl1.ImageActiveBuffer;
CurrentBuffer.Lock;
ImageData:= CurrentBuffer.GetImageData;
pPixel:=TVarData(ImageData).Varray^.data;
{pPixel points directly to the beginning of the image pixel data }
Image1.Picture.Bitmap.PixelFormat := pf24Bit;
for iY := 0 to sy - 1 do
begin
Ziel:= Image1.Picture.Bitmap.ScanLine[iY];
for iX := 0 to sx - 1 do
begin
Ziel^ := pPixel^[479-iY,iX];
Inc(Ziel);
end;
end;
CurrentBuffer.ReleaseImageData(ImageData);
CurrentBuffer.UnLock;
Image1.refresh;
end;

Stefan Geissler
April 6, 2009, 11:39:17
Dear Mr. Miller,

Thank you for your solution.

For accessing the ring light properties, you must use the VCD Properties of IC Imaging Control. In the first step, please start the "VCD Property Inspector" from the IC Imaging Control installation path in the subdirectory "bin". This program shows the properties needed for the ring light (Strobe). Play around with "Enable" and "Polarisation" to get a feeling about how to turn the light on and off.

Accessing the VCD Properties in Delphi:



VCDExposure : VCDPropertyItem;
VCDExposureRange : VCDRangeProperty;
VCDExposureAuto : VCDSwitchProperty;



The following sets up the VCD Properties for Exposure:


procedure TForm1.SetupVCDProperty();
var
VCDTemp : VCDPropertyInterface ;
begin
if icimagingcontrol1.DeviceValid = True then
begin
// The ID is VCDID_Exposure from the file classlib/include/VCDPropertyID.bas.
VCDExposure := ICImagingControl1.VCDPropertyItems.FindItem('{90D5 702E-E43B-4366-AAEB-7A7A10B448B4}');
if VCDExposure <> NIL then
begin
// The GUIDs are VCDElement_Value : VCDInterface_Range
VCDExposureRange := VCDRangeProperty(VCDExposure.Elements.FindInterfac e('{B57D3000-0AC6-4819-A609-272A33140ACA}:{99B44940-BFE1-4083-ADA1-BE703F4B8E03}'));
// Retrieve the numeric values of exposure and setup a slider.
lblExposure.Caption := inttostr(VCDExposureRange.Value);
sldExposure.Position := VCDExposureRange.Value;
sldExposure.Min := VCDExposureRange.RangeMin;
sldExposure.Max := VCDExposureRange.RangeMax;

// The GUIDs are VCDElement_Auto : VCDInterface_Switch
VCDExposureAuto := VCDSwitchProperty(VCDExposure.Elements.FindInterfa ce('{B57D3001-0AC6-4819-A609-272A33140ACA}:{99B44940-BFE1-4083-ADA1-BE703F4B8E04}'));
if VCDExposureAuto <> NIL then
begin
// Query the current value for exposure automatic and setup the check box.
if VCDExposureAuto.Switch = TRUE then
chkAutoExposure.State := cbChecked
else
chkAutoExposure.State := cbUnchecked;
end;
end;
end;
end;

procedure TForm1.OnsldExposureChange(Sender: TObject);
begin
if icimagingcontrol1.DeviceValid = True then
begin
if VCDExposureRange <> NIL then
begin
VCDExposureRange.Value := sldExposure.Position;
lblExposure.Caption := inttostr(VCDExposureRange.Value);
end;
end;
end;

procedure TForm1.OnchkAutoExposureClick(Sender: TObject);
begin
if icimagingcontrol1.DeviceValid = True then
begin
if VCDExposureAuto <> NIL then
begin
if chkAutoExposure.State = cbChecked then
VCDExposureAuto.Switch := True
else
VCDExposureAuto.Switch := False;
end;
end;
end;


The GUIDs of the properties can be found in the file:
C:\Programme\The Imaging Source Europe GmbH\IC Imaging Control 3.0\samples\vb6\Common\VCDPropertyID.bas

If you have any more questions, please feel free to ask.