![]() |
|
|
|||||||
| IC Imaging Control ActiveX Please use this forum for IC Imaging Control ActiveX support only. If you need support for the C++ Class Library or .NET version, please use the appropriate forum. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi everybody:
I´ve been working with the IC control in delphi with very amazing results, well better said the same results as your Visual Basic programs and I'm working in this moment with digital image processing. My basic question is, I have configured IC control for working with a ring buffer of size 5 I would like to know if I can have the same applications as when you have just 1 buffer, I mean, Can I make AVI Capture or capture a BMP file? I have tried to do this but nothing is happening when capturing AVI file and when trying to capture BMP file I get an error like 'The requested mode is already active' I have thought that is imposible to do this so I have changed my program so in one mode I can make AVI and BMP capture and in the other mode I can make image processing. The result is that when I switch from single buffer mode to ring buffer mode there´s no problem but when I again try to return to single buffer mode I cannot make BMP Capture. When I change from single buffer to ringbuffer I do this: IC.MemoryCurrentGrabberColorformat := ICY8; IC.ImageRingBufferSize := 5; IC.LiveCaptureContinuous := TRUE; IC.LiveCaptureLastImage := FALSE; IC.LiveDisplay := FALSE; And when doing from ringbuffer to single buffer IC.ImageRingBufferSize := 1; IC.LiveCaptureContinuous := FALSE; IC.LiveCaptureLastImage := TRUE; IC.LiveDisplay := TRUE; Obviously I'm not doing correct things so I need your great help. Thanks a lot. |
|
#2
|
||||
|
||||
|
Hello
First of all, if you capture an AVI file, image processing is not available. Also you can not save frames to BMP files, due to AVI capture. There is either AVI capture or image processing with saving to BMP files. If IC.LiveCaptureContinuous is set to TRUE, then there is no need to call MemorySnapImage explicitly. In fact, this would rise an exception, because the incoming frames are automatically saved into the ring buffer. If IC.LiveCaptureContinuous is set to TRUE, then the ImageAvailable event handler is called automatically for each incoming frame. In this handler you can access the image data, process them or save them to a bitmap file. The following sample code shows an implementation of an ImageAvailable event handler, that converts a Bayer Mosiac image from a DBK camera into an RGB colored image in real time. You may adapt it to your program. Code:
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
if iY mod 2 = 0 then
begin
// Red Green Lines
P^.a := 0;
P^.r := pPixel^[iY,iX];
P^.g := pPixel^[iY,iX+1];
P^.b := pPixel^[iY+1,iX+1];
Inc(iX );
Inc(P);
P^.a := 0;
P^.r := pPixel^[iY,iX+1];
P^.g := pPixel^[iY,iX];
P^.b := pPixel^[iY+1,iX+1];
Inc(P);
Inc(iX );
end
else
begin
// Green Blue Lines
P^.a := 0;
P^.r := pPixel^[iY+1,iX];
P^.g := pPixel^[iY,iX];
P^.b := pPixel^[iY,iX+1];
Inc(iX );
Inc(P);
P^.a := 0;
P^.r := pPixel^[iY+1,iX+1];
P^.g := pPixel^[iY,iX+1];
P^.b := pPixel^[iY,iX];
Inc(iX );
Inc(P);
end;
end;
end;
CurrentBuffer.ReleaseImageData(ImageData);
CurrentBuffer.UnLock;
Image1.refresh;
end;
__________________
Best regards Stefan IC Imaging Control Support |
|
#3
|
|||
|
|||
|
Hi again, thanks for your answer it was very good and now I have solved my problem, I can now save BMP files and AVI files using multiple buffers. The simplest program I likes to do is just using multiple buffers and then capture BMP and AVI files and now I can do it with just a little problem, when capturing AVI files in ringbuffer mode I cannot see live video running in the IC control but the AVI file is saved right, What shoul I do for having live video running?. Thanks again.
I have one new question I'm gonna write it but if you consider I need to open a new thread please just said so. I have been working with your Advanced Image Processing example and it runs ok but I would like to change MemoryCurrentGrabberColorformat from monochrome to another format like ICRGB24 I know that doing so my image change in X axis multiply by 3. My problem is that I have changed the code for sub DrawRectangleY8 and is like this: Private Sub DrawRectangleY8(Arr As Variant, Region As RECT) Const RECT_COLOR As Long = 255 Dim x, y As Long For x = 3*Region.Left To 3*Region.right Arr(x, Region.Top) = RECT_COLOR Next x For x = 3*Region.Left To 3*Region.right Arr(x, Region.bottom) = RECT_COLOR Next x For y = Region.Top To Region.bottom Arr(3*Region.Left, y) = RECT_COLOR Next y For y = Region.Top To Region.bottom Arr(3*Region.right, y) = RECT_COLOR Next y End Sub Well as I told you before I'm working with delphi but is the same as in VB. When I draw the rectangle the horizontal lines are painted perfectly white but the vertical ones are painted in blue and I don't really understand what is wrong or maybe I'm not changing the correct SUB. I would like to change the complete example for displaying an RGB color image, if you please can tell me what should I change I would really apreciate it. Thanks a lot for your help!!!! |
|
#4
|
||||
|
||||
|
Hello
Quote:
Thus, set IC.LiveDisplay to true, due to capture AVI files. As far as i can see, you did this already. Therefore i am a little bit confused. You may send your whole project as ZIP file to support@imagingcontrol.com, so i could have a look on it. Quote:
Code:
For y = Region.Top To Region.bottom
Arr(3*Region.Left, y) = RECT_COLOR
Arr(3*Region.Left+1, y) = RECT_COLOR
Arr(3*Region.Left+2, y) = RECT_COLOR
Next y
__________________
Best regards Stefan IC Imaging Control Support |
|
#5
|
|||
|
|||
|
Hi again, I'm still working with the ROI example and the color format I'm working with is ICRGB24, I have solved my problem about drawing a white rectangle in the live stream in this way:
procedure TfrmPrincipal.DrawRectangleY8(var Arr : OleVariant; Region : RECT;COLOR : integer); var x,y : integer; RECT_COLOR : integer; begin RECT_COLOR:=COLOR; For x:=3*Region.Left To 3*Region.Right do Arr[x,Region.Top]:=RECT_COLOR; For x:=3*Region.Left To 3*Region.Right do Arr[x,Region.Bottom]:=RECT_COLOR; For y:=Region.Top To Region.Bottom do begin Arr[3*Region.Left,y]:=RECT_COLOR; Arr[3*Region.Left + 1,y]:=RECT_COLOR; Arr[3*Region.Left + 2,y]:=RECT_COLOR; end; For y:=Region.Top To Region.Bottom do begin Arr[3*Region.Right,y]:=RECT_COLOR; Arr[3*Region.Right + 1,y]:=RECT_COLOR; Arr[3*Region.Right + 2,y]:=RECT_COLOR; end; end; But now I want to calculate the average RGB in the ROI, but I don't know what I'm doing wrong but when calculating the average for a Red ROI I get almost the same average as if I were calculating it for a Blue ROI, this is what I'm doing: function TfrmPrincipal.RGBlevel(var ArregloDisplay : OleVariant; r : RECT): integer; var x,y,NumPixel : integer; RGBScale : integer; begin NumPixel := 3*(r.Right - r.Left)*(r.Bottom - r.Top); RGBScale := 0; if NumPixel > 0 then begin for y:=r.Top to r.Bottom do for x:=r.Left to r.Right - 1 do RGBScale := RGBScale + ArregloDisplay[x,y] + ArregloDisplay[x+1,y] + ArregloDisplay[x + 2,y]; RGBlevel := trunc(EscalaRGB/NumPixel); end else RGBlevel := 0; end; Obviously I call this funtion with rect = ROI. Please help me It has been taken a lot of time for me to solve my problem, thanks a lot!!! |
|
#6
|
||||
|
||||
|
Hi
You may should increase x by 3, not by 1 in the line for x:=r.Left to r.Right - 1 do
__________________
Best regards Stefan IC Imaging Control Support |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Save AVI and BMP at the same time | Unregistered | IC Imaging Control ActiveX | 1 | July 29, 2003 17:13:49 |