mirror of
https://github.com/Laex/Delphi-OpenCV.git
synced 2024-11-15 07:45:53 +01:00
Add samples:
[+] cvCreateStructuringElementEx [+] cv_FindContours2 Signed-off-by: Laex <laex@bk.ru>
This commit is contained in:
parent
25197a0436
commit
71b883df3a
@ -233,17 +233,24 @@ type
|
||||
const
|
||||
CV_RNG_COEFF = Cardinal(4164903690);
|
||||
{$EXTERNALSYM CV_RNG_COEFF}
|
||||
(* ***************************************************************************************\
|
||||
* Image cType (IplImage) *
|
||||
*************************************************************************************** *)
|
||||
// CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1))
|
||||
// {
|
||||
// CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1;
|
||||
// return rng;
|
||||
// }
|
||||
function cvRNG(seed: int64 = -1): TCvRNG; inline;
|
||||
|
||||
(* ***************************************************************************************\
|
||||
* Image cType (IplImage) *
|
||||
*************************************************************************************** *)
|
||||
|
||||
{$IFNDEF HAVE_IPL}
|
||||
|
||||
(*
|
||||
* The following definitions (until #endif)'
|
||||
* is an extract from IPL headers.
|
||||
* Copyright (c) 1995 Intel Corporation.
|
||||
*)
|
||||
(*
|
||||
* The following definitions (until #endif)'
|
||||
* is an extract from IPL headers.
|
||||
* Copyright (c) 1995 Intel Corporation.
|
||||
*)
|
||||
const
|
||||
IPL_DEPTH_SIGN = $80000000;
|
||||
{$EXTERNALSYM IPL_DEPTH_SIGN}
|
||||
@ -517,6 +524,11 @@ function CV_32FC2: Integer; inline;
|
||||
CV_64FC(n)CV_MAKETYPE(CV_64F, (n));
|
||||
*)
|
||||
|
||||
// * get reference to pixel at (col,row),
|
||||
// for multi-channel images (col) should be multiplied by number of channels */
|
||||
function CV_IMAGE_ELEM(image: pIplImage; size_elemtype, row, col: Integer): Pointer; inline;
|
||||
// (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)])
|
||||
|
||||
const
|
||||
CV_AUTO_STEP = $7FFFFFFF;
|
||||
{$EXTERNALSYM CV_AUTO_STEP}
|
||||
@ -1273,7 +1285,7 @@ function CV_GET_SEQ_ELEM(const size_of_elem: Integer; seq: pCvSeq; index: Intege
|
||||
// Assert((writer).ptr <= (writer).block_max - SizeOf(elem));
|
||||
// memcpy((writer).ptr, and (elem), SizeOf(elem)); (writer).ptr := mod +SizeOf(elem) then; end;
|
||||
|
||||
function CV_CAST_8U(t : Integer) : UCHAR; inline;
|
||||
function CV_CAST_8U(t: Integer): uchar; inline;
|
||||
|
||||
(*
|
||||
/* Move reader position forward: */
|
||||
@ -1984,7 +1996,7 @@ function cvPointFrom32f(point: TCvPoint2D32f): TCvPoint; inline;
|
||||
//
|
||||
// (* ************************************ CvScalar **************************************** *)
|
||||
// (*
|
||||
//
|
||||
|
||||
// CV_INLINE CvScalar cvRealScalar( double val0 )
|
||||
// {
|
||||
// CvScalar scalar;
|
||||
@ -1992,9 +2004,9 @@ function cvPointFrom32f(point: TCvPoint2D32f): TCvPoint; inline;
|
||||
// scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
|
||||
// return scalar;
|
||||
// }
|
||||
//
|
||||
// *)
|
||||
//
|
||||
|
||||
function cvRealScalar(val0: Double): TCvScalar; inline;
|
||||
|
||||
// (* ************************************************************************************** *)
|
||||
// (* Dynamic Data structures *)
|
||||
// (* ************************************************************************************** *)
|
||||
@ -2326,9 +2338,9 @@ begin
|
||||
Result := CV_SEQ_ELEM(seq, size_of_elem, index);
|
||||
end;
|
||||
|
||||
function CV_CAST_8U(t : Integer) : UCHAR;
|
||||
function CV_CAST_8U(t: Integer): uchar;
|
||||
begin
|
||||
if (not (t and (not 255)) <> 0) then
|
||||
if (not(t and (not 255)) <> 0) then
|
||||
Result := t
|
||||
else if t > 0 then
|
||||
Result := 255
|
||||
@ -2370,4 +2382,24 @@ begin
|
||||
Result := pCvSetElem(ptr)^.flags >= 0;
|
||||
end;
|
||||
|
||||
function CV_IMAGE_ELEM(image: pIplImage; size_elemtype, row, col: Integer): Pointer; inline;
|
||||
begin
|
||||
// (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)])
|
||||
Result := image^.imageData + image^.widthStep * row + col * size_elemtype;
|
||||
end;
|
||||
|
||||
function cvRealScalar(val0: Double): TCvScalar; inline;
|
||||
begin
|
||||
Result.val[0] := val0;
|
||||
Result.val[1] := 0;
|
||||
Result.val[2] := 0;
|
||||
Result.val[3] := 0;
|
||||
end;
|
||||
|
||||
function cvRNG(seed: int64 = -1): TCvRNG; inline;
|
||||
begin
|
||||
// CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1;
|
||||
Result := iif(seed>0,seed,uint64(int64(-1)));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -499,8 +499,6 @@ procedure cvSet(mat: pCvMat; i, j: Integer; val: Single); inline; overload;
|
||||
// #define cvZero cvSetZero
|
||||
procedure cvSetZero(arr: pIplImage); cdecl;
|
||||
procedure cvZero(arr: pCvArr); cdecl;
|
||||
// procedure cvZero(arr: pIplImage); cdecl; overload;
|
||||
// procedure cvZero(arr: pCvMat); cdecl; overload;
|
||||
|
||||
{
|
||||
/* Splits a multi-channel array into the set of single-channel arrays or
|
||||
|
@ -0,0 +1,181 @@
|
||||
(* /*****************************************************************
|
||||
// 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.
|
||||
*******************************************************************
|
||||
// Original file:
|
||||
// opencv\samples\c\morphology.c
|
||||
// *************************************************************** *)
|
||||
|
||||
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
||||
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
||||
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
||||
program cv_CreateStructuringElementEx;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
{$R *.res}
|
||||
|
||||
uses
|
||||
System.SysUtils,
|
||||
uLibName in '..\..\..\include\uLibName.pas',
|
||||
highgui_c in '..\..\..\include\highgui\highgui_c.pas',
|
||||
core_c in '..\..\..\include\ñore\core_c.pas',
|
||||
Core.types_c in '..\..\..\include\ñore\Core.types_c.pas',
|
||||
imgproc.types_c in '..\..\..\include\imgproc\imgproc.types_c.pas',
|
||||
imgproc_c in '..\..\..\include\imgproc\imgproc_c.pas',
|
||||
legacy in '..\..\..\include\legacy\legacy.pas',
|
||||
calib3d in '..\..\..\include\calib3d\calib3d.pas',
|
||||
imgproc in '..\..\..\include\imgproc\imgproc.pas',
|
||||
haar in '..\..\..\include\objdetect\haar.pas',
|
||||
objdetect in '..\..\..\include\objdetect\objdetect.pas',
|
||||
tracking in '..\..\..\include\video\tracking.pas',
|
||||
Core in '..\..\..\include\ñore\core.pas';
|
||||
|
||||
Var
|
||||
src: pIplImage = nil;
|
||||
dst: pIplImage = 0;
|
||||
|
||||
element: pIplConvKernel = nil;
|
||||
element_shape: Integer = CV_SHAPE_RECT;
|
||||
|
||||
// the address of variable which receives trackbar position update
|
||||
max_iters: Integer = 10;
|
||||
open_close_pos: Integer = 0;
|
||||
erode_dilate_pos: Integer = 0;
|
||||
|
||||
// callback function for open/close trackbar
|
||||
procedure OpenClose(pos: Integer); cdecl;
|
||||
var
|
||||
n, an: Integer;
|
||||
begin
|
||||
n := open_close_pos - max_iters;
|
||||
an := iif(n > 0, n, -n);
|
||||
element := cvCreateStructuringElementEx(an * 2 + 1, an * 2 + 1, an, an, element_shape, 0);
|
||||
if (n < 0) then
|
||||
begin
|
||||
cvErode(src, dst, element, 1);
|
||||
cvDilate(dst, dst, element, 1);
|
||||
end
|
||||
else
|
||||
begin
|
||||
cvDilate(src, dst, element, 1);
|
||||
cvErode(dst, dst, element, 1);
|
||||
end;
|
||||
cvReleaseStructuringElement(element);
|
||||
cvShowImage('Open/Close', dst);
|
||||
end;
|
||||
|
||||
// callback function for erode/dilate trackbar
|
||||
procedure ErodeDilate(pos: Integer); cdecl;
|
||||
var
|
||||
n, an: Integer;
|
||||
begin
|
||||
n := erode_dilate_pos - max_iters;
|
||||
an := iif(n > 0, n, -n);
|
||||
|
||||
element := cvCreateStructuringElementEx(an * 2 + 1, an * 2 + 1, an, an, element_shape, 0);
|
||||
if (n < 0) then
|
||||
begin
|
||||
cvErode(src, dst, element, 1);
|
||||
end
|
||||
else
|
||||
begin
|
||||
cvDilate(src, dst, element, 1);
|
||||
end;
|
||||
cvReleaseStructuringElement(&element);
|
||||
cvShowImage('Erode/Dilate', dst);
|
||||
end;
|
||||
|
||||
procedure help;
|
||||
begin
|
||||
Writeln('This program demonstrated the use of the morphology operator, especially open, close, erode, dilate operations');
|
||||
Writeln('Morphology operators are built on max (close) and min (open) operators as measured by pixels covered by small structuring elements.');
|
||||
Writeln('These operators are very efficient.');
|
||||
Writeln('This program also allows you to play with elliptical, rectangluar and cross structure elements');
|
||||
Writeln('Usage: ');
|
||||
Writeln('morphologyc [image_name -- Default baboon.jpg]');
|
||||
Writeln('Hot keys: ');
|
||||
Writeln(#9'ESC - quit the program');
|
||||
Writeln(#9'r - use rectangle structuring element');
|
||||
Writeln(#9'e - use elliptic structuring element');
|
||||
Writeln(#9'c - use cross-shaped structuring element');
|
||||
Writeln(#9'SPACE - loop through all the options');
|
||||
end;
|
||||
|
||||
var
|
||||
filename: AnsiString;
|
||||
c: Integer;
|
||||
|
||||
begin
|
||||
try
|
||||
help();
|
||||
|
||||
filename := iif(ParamCount = 1, ParamStr(1), 'resource\baboon.jpg');
|
||||
src := cvLoadImage(pCvChar(@filename[1]), 1);
|
||||
if not Assigned(src) then
|
||||
begin
|
||||
Writeln('Cannot load file image %s\n', filename);
|
||||
help();
|
||||
Exit;
|
||||
end;
|
||||
|
||||
dst := cvCloneImage(src);
|
||||
|
||||
// create windows for output images
|
||||
cvNamedWindow('Open/Close', 1);
|
||||
cvNamedWindow('Erode/Dilate', 1);
|
||||
|
||||
open_close_pos := max_iters;
|
||||
erode_dilate_pos := max_iters;
|
||||
cvCreateTrackbar('iterations', 'Open/Close', @open_close_pos, max_iters * 2 + 1, OpenClose);
|
||||
cvCreateTrackbar('iterations', 'Erode/Dilate', @erode_dilate_pos, max_iters * 2 + 1, ErodeDilate);
|
||||
|
||||
while True do
|
||||
begin
|
||||
|
||||
OpenClose(open_close_pos);
|
||||
ErodeDilate(erode_dilate_pos);
|
||||
c := cvWaitKey(0);
|
||||
|
||||
if (c = 27) then
|
||||
break;
|
||||
if (c = Ord('e')) then
|
||||
element_shape := CV_SHAPE_ELLIPSE
|
||||
else if (c = Ord('r')) then
|
||||
element_shape := CV_SHAPE_RECT
|
||||
else if (c = Ord('c')) then
|
||||
element_shape := CV_SHAPE_CROSS
|
||||
else if (c = Ord(' ')) then
|
||||
element_shape := (element_shape + 1) mod 3;
|
||||
end;
|
||||
|
||||
// release images
|
||||
cvReleaseImage(src);
|
||||
cvReleaseImage(dst);
|
||||
|
||||
// destroy windows
|
||||
cvDestroyWindow('Open/Close');
|
||||
cvDestroyWindow('Erode/Dilate');
|
||||
except
|
||||
on E: Exception do
|
||||
Writeln(E.ClassName, ': ', E.Message);
|
||||
end;
|
||||
|
||||
end.
|
@ -0,0 +1,161 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{DB80687B-B1AD-41AC-957D-21DA87C6971C}</ProjectGuid>
|
||||
<MainSource>cv_CreateStructuringElementEx.dpr</MainSource>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<TargetedPlatforms>1</TargetedPlatforms>
|
||||
<AppType>Console</AppType>
|
||||
<FrameworkType>None</FrameworkType>
|
||||
<ProjectVersion>14.4</ProjectVersion>
|
||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
|
||||
<Base_Win32>true</Base_Win32>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
|
||||
<Cfg_1>true</Cfg_1>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
|
||||
<Cfg_2_Win32>true</Cfg_2_Win32>
|
||||
<CfgParent>Cfg_2</CfgParent>
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base)'!=''">
|
||||
<VerInfo_Locale>1049</VerInfo_Locale>
|
||||
<DCC_F>false</DCC_F>
|
||||
<DCC_K>false</DCC_K>
|
||||
<DCC_ExeOutput>..\..\..\bin\</DCC_ExeOutput>
|
||||
<DCC_E>false</DCC_E>
|
||||
<DCC_N>false</DCC_N>
|
||||
<DCC_ImageBase>00400000</DCC_ImageBase>
|
||||
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace)</DCC_Namespace>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;CFBundleExecutable=</VerInfo_Keys>
|
||||
<DCC_S>false</DCC_S>
|
||||
<Manifest_File>None</Manifest_File>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base_Win32)'!=''">
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||
<DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1)'!=''">
|
||||
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
|
||||
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
|
||||
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
|
||||
<DCC_DebugInformation>false</DCC_DebugInformation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
||||
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
|
||||
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
|
||||
<DCC_Optimize>false</DCC_Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<Manifest_File>None</Manifest_File>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<DCCReference Include="..\..\..\include\uLibName.pas"/>
|
||||
<DCCReference Include="..\..\..\include\highgui\highgui_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\сore\core_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\сore\Core.types_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\imgproc\imgproc.types_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\imgproc\imgproc_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\legacy\legacy.pas"/>
|
||||
<DCCReference Include="..\..\..\include\calib3d\calib3d.pas"/>
|
||||
<DCCReference Include="..\..\..\include\imgproc\imgproc.pas"/>
|
||||
<DCCReference Include="..\..\..\include\objdetect\haar.pas"/>
|
||||
<DCCReference Include="..\..\..\include\objdetect\objdetect.pas"/>
|
||||
<DCCReference Include="..\..\..\include\video\tracking.pas"/>
|
||||
<DCCReference Include="..\..\..\include\сore\core.pas"/>
|
||||
<BuildConfiguration Include="Debug">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_1</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
|
||||
<Borland.ProjectType/>
|
||||
<BorlandProject>
|
||||
<Delphi.Personality>
|
||||
<Source>
|
||||
<Source Name="MainSource">cv_CreateStructuringElementEx.dpr</Source>
|
||||
</Source>
|
||||
<VersionInfo>
|
||||
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
|
||||
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">1</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">0</VersionInfo>
|
||||
<VersionInfo Name="Release">0</VersionInfo>
|
||||
<VersionInfo Name="Build">0</VersionInfo>
|
||||
<VersionInfo Name="Debug">False</VersionInfo>
|
||||
<VersionInfo Name="PreRelease">False</VersionInfo>
|
||||
<VersionInfo Name="Special">False</VersionInfo>
|
||||
<VersionInfo Name="Private">False</VersionInfo>
|
||||
<VersionInfo Name="DLL">False</VersionInfo>
|
||||
<VersionInfo Name="Locale">1049</VersionInfo>
|
||||
<VersionInfo Name="CodePage">1251</VersionInfo>
|
||||
</VersionInfo>
|
||||
<VersionInfoKeys>
|
||||
<VersionInfoKeys Name="CompanyName"/>
|
||||
<VersionInfoKeys Name="FileDescription"/>
|
||||
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="InternalName"/>
|
||||
<VersionInfoKeys Name="LegalCopyright"/>
|
||||
<VersionInfoKeys Name="LegalTrademarks"/>
|
||||
<VersionInfoKeys Name="OriginalFilename"/>
|
||||
<VersionInfoKeys Name="ProductName"/>
|
||||
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="Comments"/>
|
||||
<VersionInfoKeys Name="CFBundleName"/>
|
||||
<VersionInfoKeys Name="CFBundleDisplayName"/>
|
||||
<VersionInfoKeys Name="CFBundleIdentifier"/>
|
||||
<VersionInfoKeys Name="CFBundleVersion"/>
|
||||
<VersionInfoKeys Name="CFBundlePackageType"/>
|
||||
<VersionInfoKeys Name="CFBundleSignature"/>
|
||||
<VersionInfoKeys Name="CFBundleAllowMixedLocalizations"/>
|
||||
<VersionInfoKeys Name="CFBundleExecutable"/>
|
||||
</VersionInfoKeys>
|
||||
</Delphi.Personality>
|
||||
<Platforms>
|
||||
<Platform value="OSX32">False</Platform>
|
||||
<Platform value="Win32">True</Platform>
|
||||
<Platform value="Win64">False</Platform>
|
||||
</Platforms>
|
||||
</BorlandProject>
|
||||
<ProjectFileVersion>12</ProjectFileVersion>
|
||||
</ProjectExtensions>
|
||||
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
|
||||
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
|
||||
</Project>
|
||||
|
||||
<!-- EurekaLog First Line
|
||||
[Exception Log]
|
||||
EurekaLog Version=7001
|
||||
DeleteMapAfterCompile=1
|
||||
Encrypt Password=""
|
||||
EurekaLog Last Line -->
|
Binary file not shown.
228
samples/LibTest/cvFindContours/cv_FindContours2.dpr
Normal file
228
samples/LibTest/cvFindContours/cv_FindContours2.dpr
Normal file
@ -0,0 +1,228 @@
|
||||
(* /*****************************************************************
|
||||
// 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.
|
||||
*******************************************************************
|
||||
// Original file:
|
||||
// opencv\samples\c\contours.c
|
||||
// *************************************************************** *)
|
||||
|
||||
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
||||
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
||||
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
||||
program cv_FindContours2;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
{$R *.res}
|
||||
|
||||
uses
|
||||
System.SysUtils,
|
||||
uLibName in '..\..\..\include\uLibName.pas',
|
||||
highgui_c in '..\..\..\include\highgui\highgui_c.pas',
|
||||
core_c in '..\..\..\include\ñore\core_c.pas',
|
||||
Core.types_c in '..\..\..\include\ñore\Core.types_c.pas',
|
||||
imgproc.types_c in '..\..\..\include\imgproc\imgproc.types_c.pas',
|
||||
imgproc_c in '..\..\..\include\imgproc\imgproc_c.pas',
|
||||
legacy in '..\..\..\include\legacy\legacy.pas',
|
||||
calib3d in '..\..\..\include\calib3d\calib3d.pas',
|
||||
imgproc in '..\..\..\include\imgproc\imgproc.pas',
|
||||
haar in '..\..\..\include\objdetect\haar.pas',
|
||||
objdetect in '..\..\..\include\objdetect\objdetect.pas',
|
||||
tracking in '..\..\..\include\video\tracking.pas',
|
||||
Core in '..\..\..\include\ñore\core.pas';
|
||||
|
||||
procedure help;
|
||||
begin
|
||||
Writeln('This program creates an image to demonstrate the use of the ''c'' contour');
|
||||
Writeln('functions: cvFindContours() and cvApproxPoly() along with the storage');
|
||||
Writeln('functions cvCreateMemStorage() and cvDrawContours().');
|
||||
Writeln('It also shows the use of a trackbar to control contour retrieval.');
|
||||
Writeln;
|
||||
Writeln('Usage :');
|
||||
Writeln('contours');
|
||||
end;
|
||||
|
||||
const
|
||||
w = 500;
|
||||
|
||||
Var
|
||||
levels: Integer = 3;
|
||||
contours: pCvSeq = nil;
|
||||
|
||||
procedure on_trackbar(pos: Integer); cdecl;
|
||||
Var
|
||||
cnt_img: pIplImage;
|
||||
_contours: pCvSeq;
|
||||
_levels: Integer;
|
||||
begin
|
||||
cnt_img := cvCreateImage(cvSize(w, w), 8, 3);
|
||||
_contours := contours;
|
||||
_levels := levels - 3;
|
||||
// (void)pos;
|
||||
|
||||
if (_levels <= 0) then // get to the nearest face to make it look more funny
|
||||
_contours := _contours^.h_next^.h_next^.h_next;
|
||||
cvZero(cnt_img);
|
||||
cvDrawContours(cnt_img, _contours, CV_RGB(255, 0, 0), CV_RGB(0, 255, 0), _levels, 3, CV_AA, cvPoint(0, 0));
|
||||
cvShowImage('contours', cnt_img);
|
||||
cvReleaseImage(cnt_img);
|
||||
end;
|
||||
|
||||
procedure findCComp(img: pIplImage);
|
||||
var
|
||||
x, y, cidx: Integer;
|
||||
mask: pIplImage;
|
||||
begin
|
||||
cidx := 1;
|
||||
mask := cvCreateImage(cvSize(img^.width + 2, img^.height + 2), 8, 1);
|
||||
cvZero(mask);
|
||||
cvRectangle(mask, cvPoint(0, 0), cvPoint(mask^.width - 1, mask^.height - 1), cvScalarAll(1), 1, 8, 0);
|
||||
|
||||
for y := 0 to img^.height - 1 do
|
||||
for x := 0 to img^.width - 1 do
|
||||
begin
|
||||
if uchar(CV_IMAGE_ELEM(mask, SizeOf(uchar), y + 1, x + 1)^) <> 0 then
|
||||
continue;
|
||||
cvFloodFill(img, cvPoint(x, y), cvScalarAll(cidx), cvScalarAll(0), cvScalarAll(0), nil, 4, mask);
|
||||
Inc(cidx);
|
||||
end;
|
||||
end;
|
||||
|
||||
Var
|
||||
i, j: Integer;
|
||||
storage: pCvMemStorage;
|
||||
img: pIplImage;
|
||||
img32f: pIplImage;
|
||||
img32s: pIplImage;
|
||||
img3: pIplImage;
|
||||
|
||||
dx, dy: Integer;
|
||||
white: TCvScalar;
|
||||
black: TCvScalar;
|
||||
angle: double;
|
||||
attrs: array [0 .. 2] of pCVChar;
|
||||
rng: TCvRNG;
|
||||
tcontours: pCvSeq;
|
||||
color: TCvScalar;
|
||||
|
||||
begin
|
||||
try
|
||||
storage := cvCreateMemStorage(0);
|
||||
img := cvCreateImage(cvSize(w, w), 8, 1);
|
||||
img32f := cvCreateImage(cvSize(w, w), IPL_DEPTH_32F, 1);
|
||||
img32s := cvCreateImage(cvSize(w, w), IPL_DEPTH_32S, 1);
|
||||
img3 := cvCreateImage(cvSize(w, w), 8, 3);
|
||||
help;
|
||||
|
||||
cvZero(img);
|
||||
|
||||
for i := 0 to 5 do
|
||||
begin
|
||||
dx := (i mod 2) * 250 - 30;
|
||||
dy := (i div 2) * 150;
|
||||
white := cvRealScalar(255);
|
||||
black := cvRealScalar(0);
|
||||
|
||||
if (i = 0) then
|
||||
begin
|
||||
for j := 0 to 9 do
|
||||
begin
|
||||
angle := (j + 5) * CV_PI / 21;
|
||||
cvLine(img, cvPoint(cvRound(dx + 100 + j * 10 - 80 * cos(angle)), cvRound(dy + 100 - 90 * sin(angle))),
|
||||
cvPoint(cvRound(dx + 100 + j * 10 - 30 * cos(angle)), cvRound(dy + 100 - 30 * sin(angle))), white, 3, 8, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
cvEllipse(img, cvPoint(dx + 150, dy + 100), cvSize(100, 70), 0, 0, 360, white, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 115, dy + 70), cvSize(30, 20), 0, 0, 360, black, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 185, dy + 70), cvSize(30, 20), 0, 0, 360, black, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 115, dy + 70), cvSize(15, 15), 0, 0, 360, white, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 185, dy + 70), cvSize(15, 15), 0, 0, 360, white, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 115, dy + 70), cvSize(5, 5), 0, 0, 360, black, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 185, dy + 70), cvSize(5, 5), 0, 0, 360, black, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 150, dy + 100), cvSize(10, 5), 0, 0, 360, black, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 150, dy + 150), cvSize(40, 10), 0, 0, 360, black, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 27, dy + 100), cvSize(20, 35), 0, 0, 360, white, -1, 8, 0);
|
||||
cvEllipse(img, cvPoint(dx + 273, dy + 100), cvSize(20, 35), 0, 0, 360, white, -1, 8, 0);
|
||||
end;
|
||||
|
||||
cvNamedWindow('image', 1);
|
||||
cvShowImage('image', img);
|
||||
cvConvert(img, img32f);
|
||||
findCComp(img32f);
|
||||
cvConvert(img32f, img32s);
|
||||
|
||||
// cvFindContours(img32s, storage, @contours, SizeOf(TCvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));
|
||||
cvFindContours(img, storage, @contours, SizeOf(TCvContour), CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));
|
||||
|
||||
attrs[0] := 'recursive';
|
||||
attrs[1] := '1';
|
||||
cvSave('result\contours.xml', contours, nil, nil, cvAttrList(@attrs));
|
||||
contours := pCvSeq(cvLoad('result\contours.xml', storage));
|
||||
|
||||
// comment this out if you do not want approximation
|
||||
contours := cvApproxPoly(contours, SizeOf(TCvContour), storage, CV_POLY_APPROX_DP, 3, 1);
|
||||
|
||||
cvNamedWindow('contours', 1);
|
||||
cvCreateTrackbar('levels+3', 'contours', @levels, 7, on_trackbar);
|
||||
|
||||
rng := CvRNG(-1);
|
||||
tcontours := contours;
|
||||
|
||||
cvCvtColor(img, img3, CV_GRAY2BGR);
|
||||
|
||||
while Assigned(tcontours^.h_next) do
|
||||
tcontours := tcontours^.h_next;
|
||||
|
||||
while not Assigned(tcontours) do
|
||||
begin
|
||||
color.val[0] := cvRandInt(rng) mod 256;
|
||||
color.val[1] := cvRandInt(rng) mod 256;
|
||||
color.val[2] := cvRandInt(rng) mod 256;
|
||||
color.val[3] := cvRandInt(rng) mod 256;
|
||||
cvDrawContours(img3, tcontours, color, color, 0, -1, 8, cvPoint(0, 0));
|
||||
if Assigned(tcontours^.v_next) then
|
||||
begin
|
||||
color.val[0] := cvRandInt(rng) mod 256;
|
||||
color.val[1] := cvRandInt(rng) mod 256;
|
||||
color.val[2] := cvRandInt(rng) mod 256;
|
||||
color.val[3] := cvRandInt(rng) mod 256;
|
||||
cvDrawContours(img3, tcontours^.v_next, color, color, 1, -1, 8, cvPoint(0, 0));
|
||||
end;
|
||||
tcontours := tcontours^.h_prev;
|
||||
end;
|
||||
|
||||
cvShowImage('colored', img3);
|
||||
on_trackbar(0);
|
||||
|
||||
cvWaitKey(0);
|
||||
cvReleaseMemStorage(storage);
|
||||
cvReleaseImage(img);
|
||||
cvReleaseImage(img32f);
|
||||
cvReleaseImage(img32s);
|
||||
cvReleaseImage(img3);
|
||||
cvDestroyAllWindows;
|
||||
|
||||
except
|
||||
on E: Exception do
|
||||
Writeln(E.ClassName, ': ', E.Message);
|
||||
end;
|
||||
|
||||
end.
|
160
samples/LibTest/cvFindContours/cv_FindContours2.dproj
Normal file
160
samples/LibTest/cvFindContours/cv_FindContours2.dproj
Normal file
@ -0,0 +1,160 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{3F1C177B-899D-4383-85FE-554DCA33D83E}</ProjectGuid>
|
||||
<MainSource>cv_FindContours2.dpr</MainSource>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<TargetedPlatforms>1</TargetedPlatforms>
|
||||
<AppType>Console</AppType>
|
||||
<FrameworkType>None</FrameworkType>
|
||||
<ProjectVersion>14.4</ProjectVersion>
|
||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
|
||||
<Base_Win32>true</Base_Win32>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
|
||||
<Cfg_1>true</Cfg_1>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
|
||||
<Cfg_2_Win32>true</Cfg_2_Win32>
|
||||
<CfgParent>Cfg_2</CfgParent>
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base)'!=''">
|
||||
<VerInfo_Locale>1049</VerInfo_Locale>
|
||||
<DCC_F>false</DCC_F>
|
||||
<DCC_K>false</DCC_K>
|
||||
<DCC_ExeOutput>..\..\..\bin\</DCC_ExeOutput>
|
||||
<DCC_E>false</DCC_E>
|
||||
<DCC_N>false</DCC_N>
|
||||
<DCC_ImageBase>00400000</DCC_ImageBase>
|
||||
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace)</DCC_Namespace>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;CFBundleExecutable=</VerInfo_Keys>
|
||||
<DCC_S>false</DCC_S>
|
||||
<Manifest_File>None</Manifest_File>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base_Win32)'!=''">
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||
<DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1)'!=''">
|
||||
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
|
||||
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
|
||||
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
|
||||
<DCC_DebugInformation>false</DCC_DebugInformation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
||||
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
|
||||
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
|
||||
<DCC_Optimize>false</DCC_Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<Manifest_File>None</Manifest_File>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<DCCReference Include="..\..\..\include\uLibName.pas"/>
|
||||
<DCCReference Include="..\..\..\include\highgui\highgui_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\сore\core_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\сore\Core.types_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\imgproc\imgproc.types_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\imgproc\imgproc_c.pas"/>
|
||||
<DCCReference Include="..\..\..\include\legacy\legacy.pas"/>
|
||||
<DCCReference Include="..\..\..\include\calib3d\calib3d.pas"/>
|
||||
<DCCReference Include="..\..\..\include\imgproc\imgproc.pas"/>
|
||||
<DCCReference Include="..\..\..\include\objdetect\haar.pas"/>
|
||||
<DCCReference Include="..\..\..\include\objdetect\objdetect.pas"/>
|
||||
<DCCReference Include="..\..\..\include\video\tracking.pas"/>
|
||||
<DCCReference Include="..\..\..\include\сore\core.pas"/>
|
||||
<BuildConfiguration Include="Debug">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_1</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
|
||||
<Borland.ProjectType/>
|
||||
<BorlandProject>
|
||||
<Delphi.Personality>
|
||||
<Source>
|
||||
<Source Name="MainSource">cv_FindContours2.dpr</Source>
|
||||
</Source>
|
||||
<VersionInfo>
|
||||
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
|
||||
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">1</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">0</VersionInfo>
|
||||
<VersionInfo Name="Release">0</VersionInfo>
|
||||
<VersionInfo Name="Build">0</VersionInfo>
|
||||
<VersionInfo Name="Debug">False</VersionInfo>
|
||||
<VersionInfo Name="PreRelease">False</VersionInfo>
|
||||
<VersionInfo Name="Special">False</VersionInfo>
|
||||
<VersionInfo Name="Private">False</VersionInfo>
|
||||
<VersionInfo Name="DLL">False</VersionInfo>
|
||||
<VersionInfo Name="Locale">1049</VersionInfo>
|
||||
<VersionInfo Name="CodePage">1251</VersionInfo>
|
||||
</VersionInfo>
|
||||
<VersionInfoKeys>
|
||||
<VersionInfoKeys Name="CompanyName"/>
|
||||
<VersionInfoKeys Name="FileDescription"/>
|
||||
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="InternalName"/>
|
||||
<VersionInfoKeys Name="LegalCopyright"/>
|
||||
<VersionInfoKeys Name="LegalTrademarks"/>
|
||||
<VersionInfoKeys Name="OriginalFilename"/>
|
||||
<VersionInfoKeys Name="ProductName"/>
|
||||
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="Comments"/>
|
||||
<VersionInfoKeys Name="CFBundleName"/>
|
||||
<VersionInfoKeys Name="CFBundleDisplayName"/>
|
||||
<VersionInfoKeys Name="CFBundleIdentifier"/>
|
||||
<VersionInfoKeys Name="CFBundleVersion"/>
|
||||
<VersionInfoKeys Name="CFBundlePackageType"/>
|
||||
<VersionInfoKeys Name="CFBundleSignature"/>
|
||||
<VersionInfoKeys Name="CFBundleAllowMixedLocalizations"/>
|
||||
<VersionInfoKeys Name="CFBundleExecutable"/>
|
||||
</VersionInfoKeys>
|
||||
</Delphi.Personality>
|
||||
<Platforms>
|
||||
<Platform value="OSX32">False</Platform>
|
||||
<Platform value="Win32">True</Platform>
|
||||
<Platform value="Win64">False</Platform>
|
||||
</Platforms>
|
||||
</BorlandProject>
|
||||
<ProjectFileVersion>12</ProjectFileVersion>
|
||||
</ProjectExtensions>
|
||||
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
|
||||
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
|
||||
</Project>
|
||||
|
||||
<!-- EurekaLog First Line
|
||||
[Exception Log]
|
||||
EurekaLog Version=7001
|
||||
DeleteMapAfterCompile=1
|
||||
EurekaLog Last Line -->
|
BIN
samples/LibTest/cvFindContours/cv_FindContours2.res
Normal file
BIN
samples/LibTest/cvFindContours/cv_FindContours2.res
Normal file
Binary file not shown.
@ -24,29 +24,30 @@
|
||||
// Ñòûðåíî ó "Header files OpenCV 2.4.3 for Delphi XE3"
|
||||
// https://code.google.com/p/opencv-delphi-new/
|
||||
///
|
||||
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
||||
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
||||
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
||||
program HandsDetect;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
{$POINTERMATH ON}
|
||||
|
||||
{$R *.res}
|
||||
|
||||
uses
|
||||
System.SysUtils,
|
||||
uLibName in '..\..\..\include\uLibName.pas',
|
||||
highgui_c in '..\..\..\include\highgui\highgui_c.pas',
|
||||
core_c in '..\..\..\include\ñore\core_c.pas',
|
||||
Core.types_c in '..\..\..\include\ñore\Core.types_c.pas',
|
||||
imgproc.types_c in '..\..\..\include\imgproc\imgproc.types_c.pas',
|
||||
imgproc_c in '..\..\..\include\imgproc\imgproc_c.pas',
|
||||
legacy in '..\..\..\include\legacy\legacy.pas',
|
||||
calib3d in '..\..\..\include\calib3d\calib3d.pas',
|
||||
imgproc in '..\..\..\include\imgproc\imgproc.pas',
|
||||
haar in '..\..\..\include\objdetect\haar.pas',
|
||||
objdetect in '..\..\..\include\objdetect\objdetect.pas',
|
||||
tracking in '..\..\..\include\video\tracking.pas',
|
||||
Core in '..\..\..\include\ñore\core.pas'
|
||||
;
|
||||
uLibName in '..\..\..\include\uLibName.pas',
|
||||
highgui_c in '..\..\..\include\highgui\highgui_c.pas',
|
||||
core_c in '..\..\..\include\ñore\core_c.pas',
|
||||
Core.types_c in '..\..\..\include\ñore\Core.types_c.pas',
|
||||
imgproc.types_c in '..\..\..\include\imgproc\imgproc.types_c.pas',
|
||||
imgproc_c in '..\..\..\include\imgproc\imgproc_c.pas',
|
||||
legacy in '..\..\..\include\legacy\legacy.pas',
|
||||
calib3d in '..\..\..\include\calib3d\calib3d.pas',
|
||||
imgproc in '..\..\..\include\imgproc\imgproc.pas',
|
||||
haar in '..\..\..\include\objdetect\haar.pas',
|
||||
objdetect in '..\..\..\include\objdetect\objdetect.pas',
|
||||
tracking in '..\..\..\include\video\tracking.pas',
|
||||
Core in '..\..\..\include\ñore\core.pas';
|
||||
|
||||
const
|
||||
NUM_FINGERS = 5;
|
||||
@ -94,7 +95,7 @@ begin
|
||||
// Óçíàåì øèðèíó è âûñîòó êàäðà
|
||||
width := cvGetCaptureProperty(Ctx.capture, CV_CAP_PROP_FRAME_WIDTH);
|
||||
height := cvGetCaptureProperty(Ctx.capture, CV_CAP_PROP_FRAME_HEIGHT);
|
||||
// WriteLn(Format('[i] %.0f x %.0f', [width, height]));
|
||||
// WriteLn(Format('[i] %.0f x %.0f', [width, height]));
|
||||
Ctx.image := cvQueryFrame(Ctx.capture);
|
||||
WriteLn('[i] Start capture.');
|
||||
end;
|
||||
@ -167,7 +168,7 @@ begin
|
||||
area := abs(cvContourArea(tmp, CV_WHOLE_SEQ, 0));
|
||||
if area > max_area then
|
||||
begin
|
||||
// WriteLn(Format('[i] area = %.1f', [area]));
|
||||
// WriteLn(Format('[i] area = %.1f', [area]));
|
||||
max_area := area;
|
||||
contour := tmp;
|
||||
end;
|
||||
@ -225,8 +226,8 @@ begin
|
||||
y := y + defect_array[i].depth_point.y;
|
||||
Ctx.defects[i] := cvPoint(defect_array[i].depth_point.x, defect_array[i].depth_point.y);
|
||||
Inc(i);
|
||||
// WriteLn(Format('[i] x = %d, y = %d', [Ctx.defects[i].x, Ctx.defects[i].y]));
|
||||
// WriteLn(Format('[i] defects.total: %d', [defects.total]));
|
||||
// WriteLn(Format('[i] x = %d, y = %d', [Ctx.defects[i].x, Ctx.defects[i].y]));
|
||||
// WriteLn(Format('[i] defects.total: %d', [defects.total]));
|
||||
end;
|
||||
|
||||
x := x div defects.total;
|
||||
@ -234,8 +235,8 @@ begin
|
||||
|
||||
Ctx.NUM_DEFECTS := defects.total;
|
||||
Ctx.hand_center := cvPoint(x, y);
|
||||
// WriteLn(Format('[i] defects.total: %d', [defects.total]));
|
||||
// WriteLn(Format('[i] hand_center: x = %d, y = %d', [Ctx.hand_center.x, Ctx.hand_center.y]));
|
||||
// WriteLn(Format('[i] defects.total: %d', [defects.total]));
|
||||
// WriteLn(Format('[i] hand_center: x = %d, y = %d', [Ctx.hand_center.x, Ctx.hand_center.y]));
|
||||
|
||||
// Compute hand radius as mean of distances of defects' depth point to hand center
|
||||
// Âû÷èñëÿåì ðàäèóñ ðóêè
|
||||
@ -247,7 +248,7 @@ begin
|
||||
end;
|
||||
|
||||
Ctx.hand_radius := Trunc(dist) div defects.total;
|
||||
// WriteLn(Format('[i] hand_radius: %d', [Ctx.hand_radius]));
|
||||
// WriteLn(Format('[i] hand_radius: %d', [Ctx.hand_radius]));
|
||||
|
||||
FreeMem(defect_array);
|
||||
end;
|
||||
|
@ -129,6 +129,12 @@
|
||||
<Projects Include="LibTest\cvCodeBook\cvCodeBook.dproj">
|
||||
<Dependencies/>
|
||||
</Projects>
|
||||
<Projects Include="LibTest\cvFindContours\cv_FindContours2.dproj">
|
||||
<Dependencies/>
|
||||
</Projects>
|
||||
<Projects Include="LibTest\cvCreateStructuringElementEx\cv_CreateStructuringElementEx.dproj">
|
||||
<Dependencies/>
|
||||
</Projects>
|
||||
<Projects Include="MultiDemo\Hello World\HelloWorld.dproj">
|
||||
<Dependencies/>
|
||||
</Projects>
|
||||
@ -551,6 +557,24 @@
|
||||
<Target Name="cvCodeBook:Make">
|
||||
<MSBuild Projects="LibTest\cvCodeBook\cvCodeBook.dproj" Targets="Make"/>
|
||||
</Target>
|
||||
<Target Name="cv_FindContours2">
|
||||
<MSBuild Projects="LibTest\cvFindContours\cv_FindContours2.dproj"/>
|
||||
</Target>
|
||||
<Target Name="cv_FindContours2:Clean">
|
||||
<MSBuild Projects="LibTest\cvFindContours\cv_FindContours2.dproj" Targets="Clean"/>
|
||||
</Target>
|
||||
<Target Name="cv_FindContours2:Make">
|
||||
<MSBuild Projects="LibTest\cvFindContours\cv_FindContours2.dproj" Targets="Make"/>
|
||||
</Target>
|
||||
<Target Name="cv_CreateStructuringElementEx">
|
||||
<MSBuild Projects="LibTest\cvCreateStructuringElementEx\cv_CreateStructuringElementEx.dproj"/>
|
||||
</Target>
|
||||
<Target Name="cv_CreateStructuringElementEx:Clean">
|
||||
<MSBuild Projects="LibTest\cvCreateStructuringElementEx\cv_CreateStructuringElementEx.dproj" Targets="Clean"/>
|
||||
</Target>
|
||||
<Target Name="cv_CreateStructuringElementEx:Make">
|
||||
<MSBuild Projects="LibTest\cvCreateStructuringElementEx\cv_CreateStructuringElementEx.dproj" Targets="Make"/>
|
||||
</Target>
|
||||
<Target Name="HelloWorld">
|
||||
<MSBuild Projects="MultiDemo\Hello World\HelloWorld.dproj"/>
|
||||
</Target>
|
||||
@ -660,13 +684,13 @@
|
||||
<MSBuild Projects="MultiDemo\FrameRecon\FrameRecon.dproj" Targets="Make"/>
|
||||
</Target>
|
||||
<Target Name="Build">
|
||||
<CallTarget Targets="cv_AddWeighted;cvSetImageROI_cvAddWeighted;cv_And;cv_Canny;cv_CopyMakeBorder;cv_CreateCameraCapture;cv_CreateTrackbar;cv_CreateVideoWriter;cv_CvtColor;cv_CvtPixToPlane;cvErode_cvDilate;cv_FindContours;cv_FloodFill;cv_GetSubRect;cv_HoughCircles;cv_HoughLines2;cv_InRangeS;cv_Laplace;cv_LoadImage;cv_LoadImage2;cv_LoadVideo;cv_MorphologyEx;cv_RandInt;cv_Resize;cv_SetImageROI;cv_SetImageROI2;cv_SetMouseCallback;cv_Smooth;cv_Sobel;cvSplit_cvMerge;cv_Save;cv_Sub;cvThreshold_cvAdaptiveThreshold;cv_Integral;cv_WarpPerspective;cv_MatchShapes;cv_WarpAffine;cv_SnakeImage;cv_CalcOpticalFlowPyrLK;cv_CreateGaussianBGModel;cv_CreateFGDStatModel;cvCodeBook;HelloWorld;VideoProcessing;FaceDetect;Stereo;CameraCaptureAndFindContours;HandsDetect;Squares;CameraCalibrate;CameraShift;minarea;fback_c;FrameRecon"/>
|
||||
<CallTarget Targets="cv_AddWeighted;cvSetImageROI_cvAddWeighted;cv_And;cv_Canny;cv_CopyMakeBorder;cv_CreateCameraCapture;cv_CreateTrackbar;cv_CreateVideoWriter;cv_CvtColor;cv_CvtPixToPlane;cvErode_cvDilate;cv_FindContours;cv_FloodFill;cv_GetSubRect;cv_HoughCircles;cv_HoughLines2;cv_InRangeS;cv_Laplace;cv_LoadImage;cv_LoadImage2;cv_LoadVideo;cv_MorphologyEx;cv_RandInt;cv_Resize;cv_SetImageROI;cv_SetImageROI2;cv_SetMouseCallback;cv_Smooth;cv_Sobel;cvSplit_cvMerge;cv_Save;cv_Sub;cvThreshold_cvAdaptiveThreshold;cv_Integral;cv_WarpPerspective;cv_MatchShapes;cv_WarpAffine;cv_SnakeImage;cv_CalcOpticalFlowPyrLK;cv_CreateGaussianBGModel;cv_CreateFGDStatModel;cvCodeBook;cv_FindContours2;cv_CreateStructuringElementEx;HelloWorld;VideoProcessing;FaceDetect;Stereo;CameraCaptureAndFindContours;HandsDetect;Squares;CameraCalibrate;CameraShift;minarea;fback_c;FrameRecon"/>
|
||||
</Target>
|
||||
<Target Name="Clean">
|
||||
<CallTarget Targets="cv_AddWeighted:Clean;cvSetImageROI_cvAddWeighted:Clean;cv_And:Clean;cv_Canny:Clean;cv_CopyMakeBorder:Clean;cv_CreateCameraCapture:Clean;cv_CreateTrackbar:Clean;cv_CreateVideoWriter:Clean;cv_CvtColor:Clean;cv_CvtPixToPlane:Clean;cvErode_cvDilate:Clean;cv_FindContours:Clean;cv_FloodFill:Clean;cv_GetSubRect:Clean;cv_HoughCircles:Clean;cv_HoughLines2:Clean;cv_InRangeS:Clean;cv_Laplace:Clean;cv_LoadImage:Clean;cv_LoadImage2:Clean;cv_LoadVideo:Clean;cv_MorphologyEx:Clean;cv_RandInt:Clean;cv_Resize:Clean;cv_SetImageROI:Clean;cv_SetImageROI2:Clean;cv_SetMouseCallback:Clean;cv_Smooth:Clean;cv_Sobel:Clean;cvSplit_cvMerge:Clean;cv_Save:Clean;cv_Sub:Clean;cvThreshold_cvAdaptiveThreshold:Clean;cv_Integral:Clean;cv_WarpPerspective:Clean;cv_MatchShapes:Clean;cv_WarpAffine:Clean;cv_SnakeImage:Clean;cv_CalcOpticalFlowPyrLK:Clean;cv_CreateGaussianBGModel:Clean;cv_CreateFGDStatModel:Clean;cvCodeBook:Clean;HelloWorld:Clean;VideoProcessing:Clean;FaceDetect:Clean;Stereo:Clean;CameraCaptureAndFindContours:Clean;HandsDetect:Clean;Squares:Clean;CameraCalibrate:Clean;CameraShift:Clean;minarea:Clean;fback_c:Clean;FrameRecon:Clean"/>
|
||||
<CallTarget Targets="cv_AddWeighted:Clean;cvSetImageROI_cvAddWeighted:Clean;cv_And:Clean;cv_Canny:Clean;cv_CopyMakeBorder:Clean;cv_CreateCameraCapture:Clean;cv_CreateTrackbar:Clean;cv_CreateVideoWriter:Clean;cv_CvtColor:Clean;cv_CvtPixToPlane:Clean;cvErode_cvDilate:Clean;cv_FindContours:Clean;cv_FloodFill:Clean;cv_GetSubRect:Clean;cv_HoughCircles:Clean;cv_HoughLines2:Clean;cv_InRangeS:Clean;cv_Laplace:Clean;cv_LoadImage:Clean;cv_LoadImage2:Clean;cv_LoadVideo:Clean;cv_MorphologyEx:Clean;cv_RandInt:Clean;cv_Resize:Clean;cv_SetImageROI:Clean;cv_SetImageROI2:Clean;cv_SetMouseCallback:Clean;cv_Smooth:Clean;cv_Sobel:Clean;cvSplit_cvMerge:Clean;cv_Save:Clean;cv_Sub:Clean;cvThreshold_cvAdaptiveThreshold:Clean;cv_Integral:Clean;cv_WarpPerspective:Clean;cv_MatchShapes:Clean;cv_WarpAffine:Clean;cv_SnakeImage:Clean;cv_CalcOpticalFlowPyrLK:Clean;cv_CreateGaussianBGModel:Clean;cv_CreateFGDStatModel:Clean;cvCodeBook:Clean;cv_FindContours2:Clean;cv_CreateStructuringElementEx:Clean;HelloWorld:Clean;VideoProcessing:Clean;FaceDetect:Clean;Stereo:Clean;CameraCaptureAndFindContours:Clean;HandsDetect:Clean;Squares:Clean;CameraCalibrate:Clean;CameraShift:Clean;minarea:Clean;fback_c:Clean;FrameRecon:Clean"/>
|
||||
</Target>
|
||||
<Target Name="Make">
|
||||
<CallTarget Targets="cv_AddWeighted:Make;cvSetImageROI_cvAddWeighted:Make;cv_And:Make;cv_Canny:Make;cv_CopyMakeBorder:Make;cv_CreateCameraCapture:Make;cv_CreateTrackbar:Make;cv_CreateVideoWriter:Make;cv_CvtColor:Make;cv_CvtPixToPlane:Make;cvErode_cvDilate:Make;cv_FindContours:Make;cv_FloodFill:Make;cv_GetSubRect:Make;cv_HoughCircles:Make;cv_HoughLines2:Make;cv_InRangeS:Make;cv_Laplace:Make;cv_LoadImage:Make;cv_LoadImage2:Make;cv_LoadVideo:Make;cv_MorphologyEx:Make;cv_RandInt:Make;cv_Resize:Make;cv_SetImageROI:Make;cv_SetImageROI2:Make;cv_SetMouseCallback:Make;cv_Smooth:Make;cv_Sobel:Make;cvSplit_cvMerge:Make;cv_Save:Make;cv_Sub:Make;cvThreshold_cvAdaptiveThreshold:Make;cv_Integral:Make;cv_WarpPerspective:Make;cv_MatchShapes:Make;cv_WarpAffine:Make;cv_SnakeImage:Make;cv_CalcOpticalFlowPyrLK:Make;cv_CreateGaussianBGModel:Make;cv_CreateFGDStatModel:Make;cvCodeBook:Make;HelloWorld:Make;VideoProcessing:Make;FaceDetect:Make;Stereo:Make;CameraCaptureAndFindContours:Make;HandsDetect:Make;Squares:Make;CameraCalibrate:Make;CameraShift:Make;minarea:Make;fback_c:Make;FrameRecon:Make"/>
|
||||
<CallTarget Targets="cv_AddWeighted:Make;cvSetImageROI_cvAddWeighted:Make;cv_And:Make;cv_Canny:Make;cv_CopyMakeBorder:Make;cv_CreateCameraCapture:Make;cv_CreateTrackbar:Make;cv_CreateVideoWriter:Make;cv_CvtColor:Make;cv_CvtPixToPlane:Make;cvErode_cvDilate:Make;cv_FindContours:Make;cv_FloodFill:Make;cv_GetSubRect:Make;cv_HoughCircles:Make;cv_HoughLines2:Make;cv_InRangeS:Make;cv_Laplace:Make;cv_LoadImage:Make;cv_LoadImage2:Make;cv_LoadVideo:Make;cv_MorphologyEx:Make;cv_RandInt:Make;cv_Resize:Make;cv_SetImageROI:Make;cv_SetImageROI2:Make;cv_SetMouseCallback:Make;cv_Smooth:Make;cv_Sobel:Make;cvSplit_cvMerge:Make;cv_Save:Make;cv_Sub:Make;cvThreshold_cvAdaptiveThreshold:Make;cv_Integral:Make;cv_WarpPerspective:Make;cv_MatchShapes:Make;cv_WarpAffine:Make;cv_SnakeImage:Make;cv_CalcOpticalFlowPyrLK:Make;cv_CreateGaussianBGModel:Make;cv_CreateFGDStatModel:Make;cvCodeBook:Make;cv_FindContours2:Make;cv_CreateStructuringElementEx:Make;HelloWorld:Make;VideoProcessing:Make;FaceDetect:Make;Stereo:Make;CameraCaptureAndFindContours:Make;HandsDetect:Make;Squares:Make;CameraCalibrate:Make;CameraShift:Make;minarea:Make;fback_c:Make;FrameRecon:Make"/>
|
||||
</Target>
|
||||
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user