Home > Back-end >  How the image of the OpenCV open TBitmap transformation?
How the image of the OpenCV open TBitmap transformation?

Time:09-17

OpenCV open image in memory and how TBitmap transformation, in order to use TImage displays?

CodePudding user response:

Can't conversion, oneself according to CV: : the data in the Mat fills a bitmap, a simple method for example, CV: : Mat (C + +) or IplImage (C), direct access to his type, col, row, and the data attribute, and then Delphi through these parameters directly to create a bitmap fill pixels can be,

CodePudding user response:

reference 1st floor summergo123321 response:
can't conversion, oneself according to CV: : the data in the Mat fills a bitmap, a simple method for example, CV: : Mat (C + +) or IplImage (C), direct access to his type, col, row, and the data attribute, and then Delphi through these parameters directly fill pixels can create a bitmap,


Is filling TBitmap Pixels [x] [y]? Can put the data into a ScanLine?

CodePudding user response:

The data is a pointer to data store, how to go? You don't fill have no other way, and also note that c + + CV: : Mat if defined as local variables (not new), and the data memory is released automatically,

CodePudding user response:

reference summergo123321 reply: 3/f
data is a pointer to data storage area, how to go? You don't fill have no other way, and also note that c + + CV: : Mat if defined as local variables (not new), and the data memory is automatically released,


I said to mean contains data replication, the data can be converted into ScanLine data?

CodePudding user response:

Should be can, first of all, had better use the 32-bit image format or a 24-bit image formats, CV can be transform, followed by ScanLine is stored in the image of a line of data, so as long as CV only data, according to the methods (such as a pointer to the first line is the starting position, the second line is the starting position and image width * 4 or 3, in circulation), copy the ScanLine is ok, can use the map, if is FMX unmap way to do it, need to be aware of the image is whether the format is consistent, otherwise to RB swaps, 2 it is to coordinate system, bitmap like starts from the lower left, VC as if from the upper left, data directly move is ok,

CodePudding user response:

reference 5 floor lvjun reply:
should be can, first of all, had better use the 32-bit image format or a 24-bit image formats, CV can be transform, followed by ScanLine is stored in the image of a line of data, so as long as CV only data, according to the methods (such as a pointer to the first line is the starting position, the second line is the starting position and image width * 4 or 3, in circulation), copy the ScanLine is ok, can use the map, if is FMX unmap way to do it, need to be aware of the image is whether the format is consistent, otherwise to RB swaps, 2 it is to coordinate system, bitmap like starts from the lower left, VC as if from the upper left, data directly move,


CV of image data and ScanLine data, R, G, B or B, G, R is consistent with the order? The end of each line pixel image data do not know to have aligned to fill?
What is the meaning of RB swap?

CodePudding user response:

Windows bitmap is according to the order of BGRA deposited, and some of the technical specification is stored in the RGBA way, if the conversion on both sides, is to change the RB channel, blunt point is four bytes of a pixel occupies the first and third it is ok to change (is the same,, check the information, or running, right to know, have a look at the color), about the alignment, you use 32-bit mode, there is no alignment problem, speed faster, access method is simple, just a point more than 24 a byte,

CodePudding user response:

I can't do any browser wrong reference point @ lvjun
How to RB swaps, CV of image data cannot be directly copied to the ScanLine? RB swaps have a function?
If the original image is 24, the alignment to consider?

CodePudding user response:

Opencv use imwrite wrote in a bitmap file and then open the most simple,

CodePudding user response:

I can't do any browser wrong reference point @ DelphiGuy

Written to a file to open, not operating speed ~ in the memory

CodePudding user response:

. A row, is nothing but a combination of data points, and a point is 3 or 4 bytes (24 and 32 bit RGB) combinations, the so-called swaps, nothing but is two bytes content change is ok, if must to code, is to use pbyte pansichar corresponding to the image data or scanline, such as the first point is j m:=p [0]; P=p [0], [2]; P [2] :=m; , 24 bits are aligned, scanline seems to be aligned at 4 byte,

CodePudding user response:

I can't do any browser wrong reference point @ lvjun

24 images, for example, do not know to have actual code?

CodePudding user response:

If internal storage structure of the Mat of opencv can and Tbitmap internal storage structure equivalence (so) that can:
Mat SRC=https://bbs.csdn.net/topics/imread (" XXX ");
The SRC. ConvertTo (SRC, some format);
BMP TBitmap *=new TBitmap;
BMP - & gt; Width=SRC. Cols;
BMP - & gt; Height=SRC. Rows;
BMP - & gt; PixelFormat=some format;
Memcpy (BMP - & gt; ScanLine [0], SRC. PTR, SRC, cols * SRC elemSize);
No test, may need to cast some types, also may need to loop each copy of a line, because can not clear internal storage structure of the Mat and BITMAP per pixel bytes aligned to 32 bits matching,

CodePudding user response:

You send in Delphi, I thought it was CB,

CodePudding user response:

I can't do any browser wrong reference point @ DelphiGuy

Delphi sentiment better ~

CodePudding user response:

And people are paying attention to this problem, with the problems
  • Related