2013-05-17 08:10:02 +02:00
|
|
|
// --------------------------------- OpenCV license.txt ---------------------------
|
|
|
|
(* // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
|
|
//
|
|
|
|
// By downloading, copying, installing or using the software you agree to this license.
|
|
|
|
// If you do not agree to this license, do not download, install,
|
|
|
|
// copy or use the software.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// License Agreement
|
|
|
|
// For Open Source Computer Vision Library
|
|
|
|
//
|
|
|
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
|
|
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
|
|
|
// Third party copyrights are property of their respective owners.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
// are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistribution's of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// * The name of the copyright holders may not be used to endorse or promote products
|
|
|
|
// derived from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// This software is provided by the copyright holders and contributors "as is" and
|
|
|
|
// any express or implied warranties, including, but not limited to, the implied
|
|
|
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
|
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
|
|
// indirect, incidental, special, exemplary, or consequential damages
|
|
|
|
// (including, but not limited to, procurement of substitute goods or services;
|
|
|
|
// loss of use, data, or profits; or business interruption) however caused
|
|
|
|
// and on any theory of liability, whether in contract, strict liability,
|
|
|
|
// or tort (including negligence or otherwise) arising in any way out of
|
|
|
|
// the use of this software, even if advised of the possibility of such damage. *)
|
|
|
|
|
|
|
|
(* / **************************************************************************************************
|
|
|
|
// 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
|
|
|
|
// **************************************************************************************************
|
|
|
|
// License:
|
|
|
|
// The contents of this file are 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/
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// Alternatively, the contents of this file may be used under the terms of the
|
|
|
|
// GNU Lesser General Public License (the "LGPL License"), in which case the
|
|
|
|
// provisions of the LGPL License are applicable instead of those above.
|
|
|
|
// If you wish to allow use of your version of this file only under the terms
|
|
|
|
// of the LGPL License and not to allow others to use your version of this file
|
|
|
|
// under the MPL, indicate your decision by deleting the provisions above and
|
|
|
|
// replace them with the notice and other provisions required by the LGPL
|
|
|
|
// License. If you do not delete the provisions above, a recipient may use
|
|
|
|
// your version of this file under either the MPL or the LGPL License.
|
|
|
|
//
|
|
|
|
// For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// **************************************************************************************************
|
|
|
|
// Warning: Using Delphi XE3 syntax!
|
|
|
|
// **************************************************************************************************
|
|
|
|
// The Initial Developer of the Original Code:
|
|
|
|
// OpenCV: open source computer vision library
|
|
|
|
// Homepage: http://opencv.org
|
|
|
|
// Online docs: http://docs.opencv.org
|
|
|
|
// Q&A forum: http://answers.opencv.org
|
|
|
|
// Dev zone: http://code.opencv.org
|
|
|
|
// **************************************************************************************************
|
|
|
|
// Original file:
|
|
|
|
// opencv\modules\highgui\include\opencv2\highgui.hpp
|
|
|
|
// ************************************************************************************************* *)
|
|
|
|
|
2013-05-14 23:36:16 +02:00
|
|
|
unit highgui;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
2013-05-21 01:35:54 +02:00
|
|
|
Uses WinApi.Windows, Mat, Core.types_c, highgui_c;
|
2013-05-15 17:55:06 +02:00
|
|
|
|
|
|
|
Type
|
2013-05-17 08:10:02 +02:00
|
|
|
|
|
|
|
// Attention!
|
|
|
|
// The sequence of function declarations interface must match the
|
|
|
|
// sequence of function declarations in the project "opencv_classes" (C++)
|
|
|
|
|
2013-05-15 17:55:06 +02:00
|
|
|
IVideoCapture = interface
|
|
|
|
['{3F605CF0-ECAC-4230-B30B-AF9BFD516C4F}']
|
2013-06-07 20:09:41 +02:00
|
|
|
function open(device: Integer): bool; overload; stdcall;
|
|
|
|
function openfilename(filename: pAnsiChar): bool; overload; stdcall;
|
2013-05-15 17:55:06 +02:00
|
|
|
function isOpened(): bool; stdcall;
|
|
|
|
procedure release(); stdcall;
|
|
|
|
|
|
|
|
function grab(): bool; stdcall;
|
2013-05-21 01:35:54 +02:00
|
|
|
function retrieve(Var image: IMat; flag: Integer): bool; stdcall;
|
|
|
|
function read(Var image: IMat): bool; stdcall;
|
2013-05-15 17:55:06 +02:00
|
|
|
|
|
|
|
function setValue(propId: Integer; value: double): bool; stdcall;
|
|
|
|
function getValue(propId: Integer): double; stdcall;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function CreateVideoCapture: IVideoCapture; overload; safecall;
|
|
|
|
function CreateVideoCapture(device: Integer): IVideoCapture; overload; safecall;
|
2013-06-07 20:09:41 +02:00
|
|
|
function CreateVideoCapture(filename: pAnsiChar): IVideoCapture; overload; safecall;
|
2013-05-15 17:55:06 +02:00
|
|
|
|
2013-05-17 08:10:02 +02:00
|
|
|
// Flags for namedWindow
|
|
|
|
Const
|
|
|
|
WINDOW_NORMAL = $00000000;
|
|
|
|
// the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
|
|
|
|
WINDOW_AUTOSIZE = $00000001; // the user cannot resize the window, the size is constrainted by the image displayed
|
|
|
|
WINDOW_OPENGL = $00001000; // window with opengl support
|
|
|
|
|
|
|
|
WINDOW_FULLSCREEN = 1; // change the window to fullscreen
|
|
|
|
WINDOW_FREERATIO = $00000100; // the image expends as much as it can (no ratio constraint)
|
|
|
|
WINDOW_KEEPRATIO = $00000000; // the ratio of the image is respected
|
|
|
|
|
|
|
|
// CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE);
|
|
|
|
procedure namedWindow(const winname: String; const flags: Integer = WINDOW_AUTOSIZE);
|
|
|
|
// CV_EXPORTS_W void destroyWindow(const String& winname);
|
|
|
|
procedure destroyWindow(const winname: String);
|
|
|
|
// CV_EXPORTS_W void destroyAllWindows();
|
|
|
|
procedure destroyAllWindows();
|
|
|
|
// CV_EXPORTS_W int startWindowThread();
|
|
|
|
function startWindowThread(): Integer;
|
|
|
|
// CV_EXPORTS_W int waitKey(int delay = 0);
|
|
|
|
function waitKey(const delay: Integer = 0): Integer;
|
|
|
|
// CV_EXPORTS_W void imshow(const String& winname, InputArray mat);
|
|
|
|
procedure imshow(const winname: String; const Mat: IMat);
|
|
|
|
// CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height);
|
|
|
|
procedure resizeWindow(const winname: String; const width, height: Integer);
|
|
|
|
// CV_EXPORTS_W void moveWindow(const String& winname, int x, int y);
|
|
|
|
procedure moveWindow(const winname: String; const x, y: Integer);
|
|
|
|
// CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value);
|
|
|
|
procedure setWindowProperty(const winname: String; const prop_id: Integer; const prop_value: double);
|
|
|
|
// CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id);
|
|
|
|
function getWindowProperty(const winname: String; const prop_id: Integer): double;
|
2013-05-21 01:35:54 +02:00
|
|
|
// CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname,
|
|
|
|
// int* value, int count,
|
|
|
|
// TrackbarCallback onChange = 0,
|
|
|
|
// void* userdata = 0);
|
|
|
|
function createTrackbar(const trackbarname: String; const winname: String; value: PInteger; count: Integer;
|
2013-06-07 20:09:41 +02:00
|
|
|
onChange: CvTrackbarCallback2 = nil; userdata: Pointer = nil): Integer;
|
2013-05-17 08:10:02 +02:00
|
|
|
|
2013-05-14 23:36:16 +02:00
|
|
|
implementation
|
|
|
|
|
2013-05-21 01:35:54 +02:00
|
|
|
Uses uLibName, cvUtils, core_c;
|
2013-05-15 17:55:06 +02:00
|
|
|
|
2013-06-07 20:09:41 +02:00
|
|
|
function CreateVideoCapture: IVideoCapture; external OpenCV_Classes_DLL name 'CreateVideoCapture';
|
|
|
|
function CreateVideoCapture(device: Integer): IVideoCapture; external OpenCV_Classes_DLL name 'CreateVideoCapture_dvc';
|
|
|
|
function CreateVideoCapture(filename: pAnsiChar): IVideoCapture;
|
|
|
|
external OpenCV_Classes_DLL name 'CreateVideoCapture_fln';
|
2013-05-15 17:55:06 +02:00
|
|
|
|
2013-05-17 08:10:02 +02:00
|
|
|
procedure namedWindow(const winname: String; const flags: Integer = WINDOW_AUTOSIZE);
|
|
|
|
begin
|
2013-06-13 16:10:58 +02:00
|
|
|
cvNamedWindow(c_str(winname), flags);
|
2013-05-17 08:10:02 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure destroyWindow(const winname: String);
|
|
|
|
begin
|
2013-06-13 16:10:58 +02:00
|
|
|
cvDestroyWindow(c_str(winname));
|
2013-05-17 08:10:02 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure destroyAllWindows();
|
|
|
|
begin
|
|
|
|
cvDestroyAllWindows();
|
|
|
|
end;
|
|
|
|
|
|
|
|
function startWindowThread(): Integer;
|
|
|
|
begin
|
|
|
|
Result := cvStartWindowThread();
|
|
|
|
end;
|
|
|
|
|
|
|
|
function waitKey(const delay: Integer = 0): Integer;
|
|
|
|
begin
|
|
|
|
Result := cvWaitKey(delay);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure imshow(const winname: String; const Mat: IMat);
|
|
|
|
Var
|
2013-05-21 01:35:54 +02:00
|
|
|
IplImage: TIplImage;
|
2013-05-17 08:10:02 +02:00
|
|
|
begin
|
2013-05-21 01:35:54 +02:00
|
|
|
IplImage._IplImage(Pointer(Mat));
|
2013-06-13 16:10:58 +02:00
|
|
|
cvShowImage(c_str(winname), @IplImage);
|
2013-05-17 08:10:02 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure resizeWindow(const winname: String; const width, height: Integer);
|
|
|
|
begin
|
2013-06-13 16:10:58 +02:00
|
|
|
cvResizeWindow(c_str(winname), width, height);
|
2013-05-17 08:10:02 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure moveWindow(const winname: String; const x, y: Integer);
|
|
|
|
begin
|
2013-06-13 16:10:58 +02:00
|
|
|
cvMoveWindow(c_str(winname), x, y);
|
2013-05-17 08:10:02 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure setWindowProperty(const winname: String; const prop_id: Integer; const prop_value: double);
|
|
|
|
begin
|
2013-06-13 16:10:58 +02:00
|
|
|
cvSetWindowProperty(c_str(winname), prop_id, prop_value);
|
2013-05-17 08:10:02 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function getWindowProperty(const winname: String; const prop_id: Integer): double;
|
|
|
|
begin
|
2013-06-13 16:10:58 +02:00
|
|
|
Result := cvGetWindowProperty(c_str(winname), prop_id);
|
2013-05-17 08:10:02 +02:00
|
|
|
end;
|
|
|
|
|
2013-05-21 01:35:54 +02:00
|
|
|
function createTrackbar(const trackbarname: String; const winname: String; value: PInteger; count: Integer;
|
2013-06-07 20:09:41 +02:00
|
|
|
onChange: CvTrackbarCallback2 = nil; userdata: Pointer = nil): Integer;
|
2013-05-21 01:35:54 +02:00
|
|
|
begin
|
2013-06-13 16:10:58 +02:00
|
|
|
Result := cvCreateTrackbar2(c_str(trackbarname), c_str(winname), value, count, onChange, userdata);
|
2013-05-21 01:35:54 +02:00
|
|
|
end;
|
|
|
|
|
2013-05-14 23:36:16 +02:00
|
|
|
end.
|