mirror of
https://github.com/Laex/Delphi-OpenCV.git
synced 2024-11-16 00:05:52 +01:00
7edf1d9684
Signed-off-by: Laentir Valetov <laex@bk.ru>
128 lines
6.5 KiB
ObjectPascal
128 lines
6.5 KiB
ObjectPascal
// *****************************************************************
|
|
// Delphi-OpenCV Demo
|
|
// Copyright (C) 2013 Project Delphi-OpenCV
|
|
// ****************************************************************
|
|
// Contributor:
|
|
// Laentir Valetov
|
|
// email:laex@bk.ru
|
|
// ****************************************************************
|
|
// You may retrieve the latest version of this file at the GitHub,
|
|
// located at git://github.com/Laex/Delphi-OpenCV.git
|
|
// ****************************************************************
|
|
// The contents of this file are used with permission, subject to
|
|
// the Mozilla Public License Version 1.1 (the "License"); you may
|
|
// not use this file except in compliance with the License. You may
|
|
// obtain a copy of the License at
|
|
// http://www.mozilla.org/MPL/MPL-1_1Final.html
|
|
//
|
|
// Software distributed under the License is distributed on an
|
|
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
// implied. See the License for the specific language governing
|
|
// rights and limitations under the License.
|
|
// *******************************************************************
|
|
|
|
program cv_CreateCameraCapture;
|
|
|
|
{$APPTYPE CONSOLE}
|
|
{$R *.res}
|
|
|
|
uses
|
|
System.SysUtils,
|
|
highgui_c,
|
|
core_c,
|
|
Core.types_c;
|
|
|
|
var
|
|
capture: PCvCapture;
|
|
width: Double;
|
|
height: Double;
|
|
frame: PIplImage;
|
|
counter: Integer;
|
|
filename: pCVChar;
|
|
c: Integer;
|
|
|
|
begin
|
|
try
|
|
// ïîëó÷àåì ëþáóþ ïîäêëþ÷¸ííóþ êàìåðó
|
|
capture := cvCreateCameraCapture(CV_CAP_ANY);
|
|
if not Assigned(capture) then
|
|
Halt;
|
|
// óçíàåì øèðèíó è âûcîòó êàäðà
|
|
width := cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
|
|
height := cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
|
|
WriteLn(Format('[i] %.0f x %.0f', [width, height]));
|
|
frame := Nil;
|
|
cvNamedWindow('capture', CV_WINDOW_AUTOSIZE);
|
|
WriteLn('[i] press Enter for capture image');
|
|
WriteLn('[i] press Space for captured image info');
|
|
WriteLn('[i] press Esc for quit!');
|
|
counter := 0;
|
|
filename := AllocMem(512);
|
|
|
|
while true do
|
|
begin
|
|
// ïîëó÷àåì êàäð
|
|
frame := cvQueryFrame(capture);
|
|
// ïîêàçûâàåì
|
|
cvShowImage('capture', frame);
|
|
case cvWaitKey(33) of
|
|
13:
|
|
begin
|
|
// cîõðàíÿåì êàäð â ôàéë
|
|
filename := pCVChar(AnsiString(Format('Image %d.jpg'#0, [counter])));
|
|
WriteLn('[i] capture - ', filename);
|
|
cvSaveImage(filename, frame);
|
|
Inc(counter);
|
|
end;
|
|
$20:
|
|
begin
|
|
WriteLn('-------- Camera info --------');
|
|
WriteLn('FRAME_WIDTH: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH)));
|
|
WriteLn('FRAME_HEIGHT: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)));
|
|
WriteLn('FPS: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_FPS)));
|
|
WriteLn('FRAME_COUNT: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT)));
|
|
WriteLn('PROP_FORMAT: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_FORMAT)));
|
|
WriteLn('PROP_MODE: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_MODE)));
|
|
WriteLn('PROP_BRIGHTNESS: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_BRIGHTNESS)));
|
|
WriteLn('PROP_CONTRAST: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_CONTRAST)));
|
|
WriteLn('PROP_SATURATION: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_SATURATION)));
|
|
// WriteLn('PROP_HUE: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_HUE)));
|
|
// WriteLn('PROP_GAIN: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_GAIN)));
|
|
WriteLn('PROP_EXPOSURE: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_EXPOSURE)));
|
|
WriteLn('PROP_CONVERT_RGB: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_CONVERT_RGB)));
|
|
WriteLn('PROP_WHITE_BALANCE_BLUE_U: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_WHITE_BALANCE_BLUE_U)));
|
|
WriteLn('PROP_RECTIFICATION: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_RECTIFICATION)));
|
|
// WriteLn('PROP_MONOCROME: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_MONOCROME)));
|
|
WriteLn('PROP_SHARPNESS: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_SHARPNESS)));
|
|
WriteLn('PROP_AUTO_EXPOSURE: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_AUTO_EXPOSURE)));
|
|
// WriteLn('PROP_GAMMA: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_GAMMA)));
|
|
WriteLn('PROP_TEMPERATURE: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_TEMPERATURE)));
|
|
WriteLn('PROP_TRIGGER: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_TRIGGER)));
|
|
WriteLn('PROP_TRIGGER_DELAY: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_TRIGGER_DELAY)));
|
|
WriteLn('PROP_WHITE_BALANCE_RED_V: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_WHITE_BALANCE_RED_V)));
|
|
WriteLn('PROP_ZOOM: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_ZOOM)));
|
|
// WriteLn('PROP_FOCUS: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_FOCUS)));
|
|
WriteLn('PROP_GUID: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_GUID)));
|
|
WriteLn('PROP_ISO_SPEED: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_ISO_SPEED)));
|
|
WriteLn('PROP_MAX_DC1394: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_MAX_DC1394)));
|
|
WriteLn('PROP_BACKLIGHT: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_BACKLIGHT)));
|
|
WriteLn('PROP_PAN: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_PAN)));
|
|
WriteLn('PROP_TILT: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_TILT)));
|
|
// WriteLn('PROP_ROLL: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_ROLL)));
|
|
// WriteLn('PROP_IRIS: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_IRIS)));
|
|
WriteLn('PROP_SETTINGS: ', Trunc(cvGetCaptureProperty(capture, CV_CAP_PROP_SETTINGS)));
|
|
end;
|
|
27:
|
|
Break;
|
|
end;
|
|
end;
|
|
// îcâîáîæäàåì ðåcóðcû
|
|
cvReleaseCapture(capture);
|
|
cvDestroyWindow('capture');
|
|
except
|
|
on E: Exception do
|
|
WriteLn(E.ClassName, ': ', E.Message);
|
|
end;
|
|
|
|
end.
|