Home > Back-end >  Opencv mat with Delphi Tbitmap how to convert
Opencv mat with Delphi Tbitmap how to convert

Time:09-17

Excuse me,
Opencv mat with Delphi Tbitmap how to convert?
Their tried, in c + +, the mat has carried on the transformation and windos Hbitmap,
But in Delphi, how Tbitmap and Hbitmap transformation, don't know how to implement

CodePudding user response:

 
The function PIplImage2bitmap (p_image: PIplImage) : TBitmap;
Var
BMP: Tbitmap;
Step: integer;
I, j: integer;
P: PbyteArray;
The begin
BMP:=Tbitmap. Create;
BMP. Width:=p_image ^. Width;
BMP. Height:=p_image ^. Height;
BMP. PixelFormat:=pf24bit;
Step:=p_image ^. WidthStep;
For I:=0 to BMP. Do Height - 1
The begin
P:=BMP ScanLine [I];
For j:=0 to BMP. Do Width - 1
The begin
Move (PByteArray (p_image ^. ImageData) ^ [I] step *, p ^ [0], step);
end;
end;
Result:=BMP;
end;

The function bitmap2PIplImage (p_bmp: TBitmap) : PIplImage;
Var
Image: PIplImage;
Step: integer;
I, j: integer;
P: PbyteArray;
P2: pointer;
The begin
//result:=nil;
If p_bmp & lt;> Nil then
The begin
If p_bmp. PixelFormat=pf24bit then
The begin
Image:=cvCreateImage (CvSize (p_bmp. Width, p_bmp. Height), IPL_DEPTH_8U, 3);
Step: image=^. WidthStep;
P2: image=^. ImageData;
For I:=0 to p_bmp. Do Height - 1
The begin
P:=p_bmp ScanLine [I];
Move (p ^ [0], P2 ^, step);
PAnsiChar (p2) :=PAnsiChar (p2) + step;
end;
Result:=image;
End
The else
The begin
Raise the exception. Create (' This pixelFormat is not implemented! ');
end;
End
The else
Raise the exception. Create (' p_bmp not assigned in the function bitmap2cv! ');
end;

CodePudding user response:

Thank you for your reply,,, thank you thank you

CodePudding user response:

Looks like you are to be used Delphi do some image processing, after many communication ah,
  • Related