Signed-off-by: Laentir Valetov <laex@bk.ru>
This commit is contained in:
Laentir Valetov 2016-10-25 12:06:22 +04:00
parent b8de486aae
commit 2b3b89fb4b
15 changed files with 155 additions and 66 deletions

View File

@ -14,15 +14,7 @@ Files: msvcp120.dll, msvcr120.dll, msvcp120d.dll, msvcr120d.dll
(1) 32-bit in the "Delphi-OpenCV\redist\VC2013x86\"
(2) 64-bit in the "Delphi-OpenCV\redist\VC2013x64\"
```
* Shared library FFMPEG for Windows can be downloaded from [here][5] (build ffmpeg-20160710-d4c8e93)<br>
libavutil 55. 28.100 / 55. 28.100<br>
libavcodec 57. 50.100 / 57. 50.100<br>
libavformat 57. 41.100 / 57. 41.100<br>
libavdevice 57. 0.102 / 57. 0.102<br>
libavfilter 6. 47.100 / 6. 47.100<br>
libswscale 4. 1.100 / 4. 1.100<br>
libswresample 2. 1.100 / 2. 1.100<br>
libpostproc 54. 0.100 / 54. 0.100<br>
* Shared library FFMPEG 3.1.4 for Windows can be downloaded from [here][5]<br>
```
(3) FFmpeg 32-bit Shared
(4) FFmpeg 64-bit Shared

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -178,7 +178,7 @@ end;
procedure TFaceRecognizer.load(const filename: string);
begin
FaceRecognizerLoad(FData, filename.AsPAnsiChar);
FaceRecognizerLoad(FData, c_str(filename));
end;
procedure TFaceRecognizer.predict(src: pIplImage; var lab: Integer; var confidence: double);
@ -195,7 +195,7 @@ end;
procedure TFaceRecognizer.save(const filename: string);
begin
FaceRecognizerSave(FData, filename.AsPAnsiChar);
FaceRecognizerSave(FData, c_str(filename));
end;
procedure TFaceRecognizer.train(src: TInputArrayOfMat; labels: TInputArrayOfInteger);

View File

@ -35,23 +35,44 @@ Uses
ocv.core_c,
ocv.core.types_c;
// CV_EXPORTS bool initModule_features2d();
function initModule_features2d: cbool; cdecl;
type
TKeyPoint = record
pt: TcvPoint2f; // !< coordinates of the keypoints
size: Single; // !< diameter of the meaningful keypoint neighborhood
angle: Single; // !< computed orientation of the keypoint (-1 if not applicable);
// !< it's in [0,360) degrees and measured relative to
// !< image coordinate system, ie in clockwise.
response: Single; // !< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling
octave: Integer; // !< octave (pyramid layer) from which the keypoint has been extracted
class_id: Integer; // !< object class (if the keypoints need to be clustered by an object they belong to)
end;
// ---------------------------- KeyPoint --------------------------
pKeyPoint = ^TKeyPoint;
TKeyPointArray = TArray<TKeyPoint>;
TKeyPointArrayOfArray = TArray<TKeyPointArray>;
TKeyPoint = record
pt: TcvPoint2f; // !< coordinates of the keypoints
size: Float; // !< diameter of the meaningful keypoint neighborhood
angle: Float; // !< computed orientation of the keypoint (-1 if not applicable);
// !< it's in [0,360) degrees and measured relative to
// !< image coordinate system, ie in clockwise.
response: Float; // !< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling
octave: Integer; // !< octave (pyramid layer) from which the keypoint has been extracted
class_id: Integer; // !< object class (if the keypoints need to be clustered by an object they belong to)
procedure KeyPoint(_pt: TcvPoint2f; _size: Float; _angle: Float = -1; _response: Float = 0; _octave: Integer = 0;
_class_id: Integer = -1); overload;
procedure KeyPoint(x: Float; y: Float; _size: Float; _angle: Float = -1; _response: Float = 0; _octave: Integer = 0;
_class_id: Integer = -1); overload;
function hash: size_t;
procedure convert(const keypoints: TKeyPointArray; Var points2f: TArrayOfcvPoint2f); overload;
procedure convert(const points2f: TArrayOfcvPoint2f; Var keypoints: TKeyPointArray); overload;
function overlap(const kp1, kp2: TKeyPoint): Float;
end;
// ! writes vector of keypoints to the file storage
// CV_EXPORTS void write(FileStorage& fs, const string& name, const vector<KeyPoint>& keypoints);
// ! reads vector of keypoints from the specified file storage node
// CV_EXPORTS void read(const FileNode& node, CV_OUT vector<KeyPoint>& keypoints);
// ---------------------------- KeyPointsFilter --------------------------
// class CV_EXPORTS KeyPointsFilter
// ---------------------------- FeatureDetector --------------------------
const
@ -185,6 +206,8 @@ uses
ocv.utils,
ocv.lib;
function initModule_features2d; external features2d_lib name '?initModule_features2d@cv@@YA_NXZ';
{ TFeatureDetector }
function Create_FeatureDetector(const detectorType: pAnsiChar): TOpenCVClass; stdcall; external opencv_classes_lib name '_Create_FeatureDetector@4';
@ -279,4 +302,45 @@ begin
Result := Empty_DescriptorExtractor(FData);
end;
{ TKeyPoint }
procedure TKeyPoint.KeyPoint(_pt: TcvPoint2f; _size, _angle, _response: Float; _octave, _class_id: Integer);
begin
pt := _pt;
size := _size;
angle := _angle;
response := _response;
octave := _octave;
class_id := _class_id;
end;
procedure TKeyPoint.convert(const keypoints: TKeyPointArray; var points2f: TArrayOfcvPoint2f);
begin
end;
procedure TKeyPoint.convert(const points2f: TArrayOfcvPoint2f; var keypoints: TKeyPointArray);
begin
end;
function TKeyPoint.hash: size_t;
begin
end;
procedure TKeyPoint.KeyPoint(x, y, _size, _angle, _response: Float; _octave, _class_id: Integer);
begin
KeyPoint(CvPoint2f(x, y), _size, _angle, _response, _octave, _class_id);
end;
function TKeyPoint.overlap(const kp1, kp2: TKeyPoint): Float;
begin
end;
initialization
initModule_features2d;
end.

View File

@ -395,7 +395,7 @@ constructor TVideoCapture.Create(const FileName: String);
begin
Create;
if Assigned(FData) then
_VideoCaptureOpenFileName(FData, FileName.AsPAnsiChar);
_VideoCaptureOpenFileName(FData, c_str(filename));
end;
constructor TVideoCapture.Create;
@ -423,7 +423,7 @@ end;
function TVideoCapture.Open(const FileName: String): cbool;
begin
if Assigned(FData) then
Result := _VideoCaptureOpenFileName(FData, FileName.AsPAnsiChar)
Result := _VideoCaptureOpenFileName(FData, c_str(filename))
else
Result := false;
end;
@ -453,12 +453,12 @@ end;
procedure namedWindow(const winname: String; const flags: integer = WINDOW_AUTOSIZE);
begin
cvNamedWindow(winname.AsPAnsiChar, flags);
cvNamedWindow(c_str(winname), flags);
end;
procedure destroyWindow(const winname: String);
begin
cvDestroyWindow(winname.AsPAnsiChar);
cvDestroyWindow(c_str(winname));
end;
procedure destroyAllWindows();
@ -481,38 +481,38 @@ Var
IplImage: TIplImage;
begin
IplImage.InitFromMat(Mat);
cvShowImage(winname.AsPAnsiChar, @IplImage);
cvShowImage(c_str(winname), @IplImage);
end;
procedure resizeWindow(const winname: String; const width, height: integer);
begin
cvResizeWindow(winname.AsPAnsiChar, width, height);
cvResizeWindow(c_str(winname), width, height);
end;
procedure moveWindow(const winname: String; const x, y: integer);
begin
cvMoveWindow(winname.AsPAnsiChar, x, y);
cvMoveWindow(c_str(winname), x, y);
end;
procedure setWindowProperty(const winname: String; const prop_id: integer; const prop_value: double);
begin
cvSetWindowProperty(winname.AsPAnsiChar, prop_id, prop_value);
cvSetWindowProperty(c_str(winname), prop_id, prop_value);
end;
function getWindowProperty(const winname: String; const prop_id: integer): double;
begin
Result := cvGetWindowProperty(winname.AsPAnsiChar, prop_id);
Result := cvGetWindowProperty(c_str(winname), prop_id);
end;
function createTrackbar(const trackbarname: String; const winname: String; Value: PInteger; count: integer;
onChange: TCvTrackbarCallback2 = nil; userdata: Pointer = nil): integer;
begin
Result := cvCreateTrackbar2(trackbarname.AsPAnsiChar, winname.AsPAnsiChar, Value, count, onChange, userdata);
Result := cvCreateTrackbar2(c_str(trackbarname), c_str(winname), Value, count, onChange, userdata);
end;
function imread(const FileName: string; flag: integer): IMat;
begin
Result := TMat.Create(cvLoadImage(FileName.AsPAnsiChar, flag));
Result := TMat.Create(cvLoadImage(c_str(FileName), flag));
end;
end.

View File

@ -233,7 +233,7 @@ end;
function TCascadeClassifier.load(const FileName: String): cbool;
begin
Result := _get_CascadeClassifier_load(FData, FileName.AsPAnsiChar);
Result := _get_CascadeClassifier_load(FData, c_str(FileName));
end;
function TCascadeClassifier.setImage(Image: IMat): cbool;

View File

@ -207,7 +207,16 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployClass Name="ProjectiOSDeviceResourceRules"/>
<DeployClass Name="DependencyModule">
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.dll;.bpl</Extensions>
</Platform>
<Platform Name="OSX32">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXResource">
<Platform Name="OSX32">
<RemoteDir>Contents\Resources</RemoteDir>
@ -519,16 +528,7 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DependencyModule">
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.dll;.bpl</Extensions>
</Platform>
<Platform Name="OSX32">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceResourceRules"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>

View File

@ -2707,24 +2707,29 @@ procedure TocvCommonMathOperation.GetImagesForTransorm(out Source1: IocvImage; o
Var
s1, s2, M: IocvImage;
begin
Source1 := VideoSource.Image;
DoGetSourceImage(s2);
DoGetMaskImage(M);
if Assigned(s2) and ((s1.Width <> s2.Width) or (s1.height <> s2.height)) then
if Assigned(VideoSource) then
begin
Source2 := s1.Same;
cvResize(s2.IpImage, Source2.IpImage, Integer(TransformInterpolation));
end
else
Source2 := s2;
Source1 := VideoSource.Image;
DoGetSourceImage(s2);
DoGetMaskImage(M);
if Assigned(s2) and ((s1.Width <> s2.Width) or (s1.height <> s2.height)) then
begin
Source2 := s1.Same;
cvResize(s2.IpImage, Source2.IpImage, Integer(TransformInterpolation));
end
else
Source2 := s2;
if Assigned(M) and ((s1.Width <> M.Width) or (s1.height <> M.height)) then
begin
Mask := s1.Same;
cvResize(M.IpImage, Mask.IpImage, Integer(TransformInterpolation));
if Assigned(M) and ((s1.Width <> M.Width) or (s1.height <> M.height)) then
begin
Mask := s1.Same;
cvResize(M.IpImage, Mask.IpImage, Integer(TransformInterpolation));
end
else
Mask := M;
end
else
Mask := M;
Source2 := Source1;
end;
procedure TocvCommonMathOperation.SetVideoSource_Source2(const Value: IocvDataSource);

View File

@ -756,6 +756,7 @@ type
TcvPoint2f = TCvPoint2D32f;
pcvPoint2f = pCvPoint2D32f;
TArrayOfcvPoint2f = TArray<TcvPoint2f>;
pCvPoint3D32f = ^TCvPoint3D32f;
@ -2919,3 +2920,4 @@ CV_SEQ_CHAIN := (CV_SEQ_KIND_CURVE or CV_SEQ_ELTYPE_CODE);
CV_SEQ_CHAIN_CONTOUR := (CV_SEQ_FLAG_CLOSED or CV_SEQ_CHAIN);
end.

View File

@ -112,6 +112,26 @@ highgui_lib = {$IFDEF MSWINDOWS}
{$ENDIF}
{$ENDIF}
// -------------------------------
features2d_lib = {$IFDEF MSWINDOWS}
CV_DLL_DIR + 'opencv_' +
{$IFDEF DelphiOCVVersion_29}
'features2d' +
{$ELSEIF DEFINED( DelphiOCVVersion_30)}
'world' +
{$ENDIF}
CV_VERSION_DLL {$IFDEF DEBUG} + 'd'{$ENDIF} + '.dll';
{$ELSE}
{$IFDEF MACOS}
'opencv_features2d.dylib';
{$ELSE}
{$IFDEF ANDROID}
'libopencv_features2d.so';
{$ELSE}
'libopencv_features2d.so';
{$ENDIF}
{$ENDIF}
{$ENDIF}
// -------------------------------
imgproc_lib = {$IFDEF MSWINDOWS}
CV_DLL_DIR + 'opencv_' +
{$IFDEF DelphiOCVVersion_29}

View File

@ -88,11 +88,12 @@ function CropIplImage(const src: PIplImage; const roi: TCvRect): PIplImage;
procedure ocvRGBToHSV(const R, G, B: byte; out _H, _S, _V: byte);
procedure ocvHSVToRGB(const _H, _S, _V: byte; out _R, _G, _B: byte);
{$IFDEF DELPHIXE3_UP}
Type
TStringAnsiHelper = record helper for
String
TStringAnsiHelper = record helper for String
function AsPAnsiChar: PAnsiChar;
end;
{$ENDIF}
implementation
@ -104,12 +105,14 @@ uses
{$ENDIF}
ocv.core_c, System.Math;
{$IFDEF DELPHIXE3_UP}
{ TStringAnsiHelper }
function TStringAnsiHelper.AsPAnsiChar: PAnsiChar;
begin
Result := c_str(Self);
end;
{$ENDIF}
function BitmapToIplImage(const bitmap:
{$IFDEF DELPHIXE2_UP}Vcl.Graphics.TBitmap{$ELSE}Graphics.TBitmap{$ENDIF}): PIplImage;

View File

@ -29,7 +29,7 @@ namespace cv
std::vector<KeyPoint>* kp = new std::vector<KeyPoint>();
ICLASS_API void __stdcall detect_FeatureDetector(const FeatureDetector* r, IplImage* image,
CV_OUT int &keypointcount, CV_OUT _KeyPoint* &keypoints, IplImage* mask)
CV_OUT size_t &keypointcount, CV_OUT _KeyPoint* &keypoints, IplImage* mask)
{
//std::vector<KeyPoint>* kp = new std::vector<KeyPoint>();
//kp.clear();

View File

@ -22,6 +22,7 @@
<ProjectGuid>{78DEF71B-AE48-44A1-9BEF-F517051EBF8F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>opencv_classes</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -75,10 +76,11 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>D:\opencv\build\include\;$(IncludePath)</IncludePath>
<LibraryPath>D:\OpenCV\build\x86\vc12\staticlib\;$(LibraryPath)</LibraryPath>
<LibraryPath>D:\OpenCV\build\x64\vc12\lib\;$(LibraryPath)</LibraryPath>
<LinkIncremental>true</LinkIncremental>
<TargetExt>2413d.dll</TargetExt>
<OutDir>..\..\bin\win64\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
@ -90,9 +92,10 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetExt>2413.dll</TargetExt>
<IncludePath>D:\opencv\build\include\;$(IncludePath)</IncludePath>
<LibraryPath>D:\OpenCV\build\x86\vc12\staticlib\;$(LibraryPath)</LibraryPath>
<LibraryPath>D:\OpenCV\build\x64\vc12\lib\;$(LibraryPath)</LibraryPath>
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\bin\win64\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -117,7 +120,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>opencv_ts300d.lib;opencv_world300d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_calib3d2413d.lib;opencv_contrib2413d.lib;opencv_core2413d.lib;opencv_features2d2413d.lib;opencv_flann2413d.lib;opencv_gpu2413d.lib;opencv_highgui2413d.lib;opencv_imgproc2413d.lib;opencv_legacy2413d.lib;opencv_ml2413d.lib;opencv_nonfree2413d.lib;opencv_objdetect2413d.lib;opencv_ocl2413d.lib;opencv_photo2413d.lib;opencv_stitching2413d.lib;opencv_superres2413d.lib;opencv_ts2413d.lib;opencv_video2413d.lib;opencv_videostab2413d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -151,7 +154,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>opencv_ts300.lib;opencv_world300.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_calib3d2413.lib;opencv_contrib2413.lib;opencv_core2413.lib;opencv_features2d2413.lib;opencv_flann2413.lib;opencv_gpu2413.lib;opencv_highgui2413.lib;opencv_imgproc2413.lib;opencv_legacy2413.lib;opencv_ml2413.lib;opencv_nonfree2413.lib;opencv_objdetect2413.lib;opencv_ocl2413.lib;opencv_photo2413.lib;opencv_stitching2413.lib;opencv_superres2413.lib;opencv_ts2413.lib;opencv_video2413.lib;opencv_videostab2413.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>