2013-04-09 12:41:27 +02:00
|
|
|
|
(* /*****************************************************************
|
|
|
|
|
// 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.
|
|
|
|
|
******************************************************************* *)
|
2013-03-23 18:01:36 +01:00
|
|
|
|
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
|
|
|
|
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
|
|
|
|
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
2013-03-27 23:20:08 +01:00
|
|
|
|
program cv_CreateCameraCapture;
|
2013-01-01 13:29:34 +01:00
|
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
2013-05-26 10:50:18 +02:00
|
|
|
|
highgui_c,
|
|
|
|
|
core_c,
|
|
|
|
|
Core.types_c;
|
2013-01-01 13:29:34 +01:00
|
|
|
|
|
2013-05-21 10:53:30 +02:00
|
|
|
|
var
|
2013-01-01 13:29:34 +01:00
|
|
|
|
capture: PCvCapture;
|
|
|
|
|
width: Double;
|
|
|
|
|
height: Double;
|
|
|
|
|
frame: PIplImage;
|
|
|
|
|
counter: Integer;
|
|
|
|
|
filename: pCVChar;
|
|
|
|
|
c: Integer;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
try
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2013-04-05 13:36:47 +02:00
|
|
|
|
capture := cvCreateCameraCapture(CV_CAP_ANY);
|
2013-01-01 13:29:34 +01:00
|
|
|
|
if not Assigned(capture) then
|
|
|
|
|
Halt;
|
2013-04-18 08:34:16 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><>c<EFBFBD><63><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
2013-01-01 13:29:34 +01:00
|
|
|
|
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);
|
2013-06-07 20:09:41 +02:00
|
|
|
|
WriteLn('[i] press Enter for capture image');
|
|
|
|
|
WriteLn('[i] press Space for captured image info');
|
|
|
|
|
WriteLn('[i] press Esc for quit!');
|
2013-01-01 13:29:34 +01:00
|
|
|
|
counter := 0;
|
|
|
|
|
filename := AllocMem(512);
|
|
|
|
|
|
|
|
|
|
while true do
|
|
|
|
|
begin
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
frame := cvQueryFrame(capture);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvShowImage('capture', frame);
|
2013-06-07 20:09:41 +02:00
|
|
|
|
case cvWaitKey(33) of
|
|
|
|
|
13:
|
|
|
|
|
begin
|
|
|
|
|
// c<><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
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;
|
2013-01-01 13:29:34 +01:00
|
|
|
|
end;
|
|
|
|
|
end;
|
2013-04-18 08:34:16 +02:00
|
|
|
|
// <20>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>c<EFBFBD><63>c<EFBFBD>
|
2013-01-01 13:29:34 +01:00
|
|
|
|
cvReleaseCapture(capture);
|
|
|
|
|
cvDestroyWindow('capture');
|
|
|
|
|
except
|
|
|
|
|
on E: Exception do
|
|
|
|
|
WriteLn(E.ClassName, ': ', E.Message);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|