1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111:
| unit Videoauswertung;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ClipBrd;
type PixArray = Array [1..3] of Byte; TForm1 = class(TForm) Panel1: TPanel; Button1: TButton; Image1: TImage; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1; handle2:THandle; i, j, x, y, R, G, B: integer; zwischensumme, endsumme: integer; p: ^PixArray;
const WM_CAP_DRIVER_CONNECT = WM_USER + 10; WM_CAP_EDIT_COPY = WM_USER + 30; WM_CAP_SET_PREVIEW = WM_USER + 50; WM_CAP_SET_OVERLAY = WM_USER + 51; WM_CAP_SET_PREVIEWRATE = WM_USER + 52;
implementation
{$R *.dfm}
function capCreateCaptureWindow(lpszWindowName: LPCSTR; dwStyle: DWORD; x, y, nWidth, nHeight: integer; hwndParent: HWND; nID: integer): HWND; stdcall; external 'AVICAP32.DLL' name 'capCreateCaptureWindowA';
procedure TForm1.Button1Click(Sender: TObject); begin SendMessage( handle2, WM_CAP_EDIT_COPY, 1, 0 ); Image1.Picture.Bitmap.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);
zwischensumme:=1; endsumme:=1; i:=0; j:=0;
for i:=0 to image1.Picture.bitmap.Height-1 do begin p:= image1.Picture.bitmap.ScanLine[i]; for j:=0 to image1.Picture.Bitmap.Width-1 do begin B:=p^[1]; G:=p^[2]; R:=p^[3]; zwischensumme:= R + G + B; if zwischensumme > endsumme then begin endsumme:=zwischensumme; x:=j; y:=i; end; Inc(p); end;
end; form1.image1.canvas.pen.color:=clRed; form1.Image1.Canvas.MoveTo(x,0); form1.Image1.Canvas.LineTo(x,480); form1.Image1.Canvas.MoveTo(0,y); form1.Image1.Canvas.LineTo(640,y);
form1.Caption:='XY-Koordinaten: '+IntToStr(x)+' '+IntToStr(Y)+' Endsumme = '+IntToStr(endsumme); end;
procedure TForm1.FormCreate(Sender: TObject); begin handle2 := capCreateCaptureWindow('Video',ws_child+ws_visible, 0, 0, 640, 480, Panel1.Handle, 1); SendMessage(handle2, WM_CAP_DRIVER_CONNECT, 0, 0); SendMessage(handle2, WM_CAP_SET_PREVIEWRATE, 30, 0); sendMessage(handle2, WM_CAP_SET_OVERLAY, 1, 0); SendMessage(handle2, wm_cap_set_preview, 1, 0); end;
end. |