I need to compare 2 pictures and find pixels that are different with specified threshold.
Now I’m doing it just programmatically in for loop, it take about 3 seconds for small 600×400 picture.
I’m wondering if there a way to do it faster using OpenGL, DirectX, CUDA or something like this? So it will use GPU and not just CPU.
Notice that in output I need an array of different pixels, not just boolean value depending on if it same picture or not.
So I looked at source in delphi and it look like this:
function TCanvas.GetPixel(X, Y: Integer): TColor;
begin
RequiredState([csHandleValid]);
GetPixel := Windows.GetPixel(FHandle, X, Y);
end;
Seems like it calls WinAPI function GetPixel() each time. Probably that’s why it’s so slow.
So now my question is: is there a way to get whole array of pixels via WinAPI? I’m working with a screenshot that have HBITMAP, so it will not be a problem to use it with WinAPI.
Since you are using delphi , you can load the images in a TBitmap and then use the
ScanLineproperty to fast access the pixels of a bitmap.