Итак добрался я и до этого проекта и малость усовершенствовал .


(Скрин чуть отредактирован (в Wine понятное дело камера не доступна, а в винду перезагружаться лень ))
Truba_DS_0_003.7z (Программа + исходники )
Датчик движения (с довольно интересным визуальным эффектом из серии "сам не ожидал" ) в первом приближении тоже работает !
+ Может кому пригодится эти две процедуры
Первая FastBW "Быстрое обесцвечивание"
и вторая FastBWComp "Оригинальное сравнение " двух кадров для датчика движения .
( лучше пока не придумал )
Код: Выделить всё
Procedure FastBW(Var Bitmap: TBitmap);
Type
RGB1=Record R,G,B : byte; end;
var
X, Y: Integer;
PixelPtr: PInteger;
PixelRowPtr: PInteger;
BytePerPixel: Integer;
BW:Byte;
PRGB:^RGB1;
begin
try
Bitmap.BeginUpdate(False);
PixelRowPtr := PInteger(Bitmap.RawImage.Data);
BytePerPixel := Bitmap.RawImage.Description.BitsPerPixel div 8;
for Y := 0 to Bitmap.Height - 1 do begin
PixelPtr := PixelRowPtr;
for X := 0 to Bitmap.Width - 1 do begin
PRGB:=Pointer(PixelPtr);
With PRGB^ do begin BW:=(R+g+b) Div 3;
R:=BW;G:=BW;B:=BW;
end;
Inc(PByte(PixelPtr), BytePerPixel);
end;
Inc(PByte(PixelRowPtr),Bitmap.RawImage.Description.BytesPerLine);
end;
finally
Bitmap.EndUpdate(False);
end;
end;
Procedure FastBWComp(C:Byte;Var Bitmap,B: TBitmap);
Type
RGB1=Record R,G,B : byte; end;
var
X, Y: Integer;
PixelPtr,PixelPtr2: PInteger;
PixelRowPtr,PixelRowPtr2: PInteger;
BytePerPixel: Integer;
BW:Byte;
PRGB,PRGB2:^RGB1;
begin
try
Bitmap.BeginUpdate(False);
PixelRowPtr := PInteger(Bitmap.RawImage.Data);
PixelRowPtr2 := PInteger(B.RawImage.Data);
BytePerPixel := Bitmap.RawImage.Description.BitsPerPixel div 8;
for Y := 0 to Bitmap.Height - 1 do begin
PixelPtr := PixelRowPtr;
PixelPtr2 := PixelRowPtr2;
for X := 0 to Bitmap.Width - 1 do begin
PRGB:=Pointer(PixelPtr); PRGB2:=Pointer(PixelPtr2);
If (PRGB^.R = PRGB^.G) and (Abs(PRGB^.R - PRGB2^.R) >c) then
With PRGB^ do begin
R:=0;B:=0;
end else
begin
PRGB^.R:=PRGB2^.G;
PRGB^.B:=PRGB2^.G;
end ;
Inc(PByte(PixelPtr), BytePerPixel);
Inc(PByte(PixelPtr2), BytePerPixel);
end;
Inc(PByte(PixelRowPtr),Bitmap.RawImage.Description.BytesPerLine);
Inc(PByte(PixelRowPtr2),Bitmap.RawImage.Description.BytesPerLine);
end;
finally
Bitmap.EndUpdate(False);
end;
end;
Зы
Интересно сделать выделение движения не цветом а рамкой ...
Может кто посоветует как это можно сделать ?