mirror of
https://github.com/Laex/Delphi-OpenCV.git
synced 2024-11-16 16:25:53 +01:00
ba000c1405
LibTest [+] cv_CalcOpticalFlowPyrLK [+] cv_SnakeImage MultiDemo [+] CameraShift [+] Squares Signed-off-by: Laex <laex@bk.ru>
74 lines
1.7 KiB
ObjectPascal
74 lines
1.7 KiB
ObjectPascal
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
|
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
|
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
|
program cv_WarpAffine;
|
|
|
|
{$APPTYPE CONSOLE}
|
|
{$R *.res}
|
|
|
|
uses
|
|
System.SysUtils,
|
|
{$I ..\..\uses_include.inc}
|
|
;
|
|
|
|
const
|
|
filename = 'Resource\cat2.jpg';
|
|
|
|
var
|
|
src: pIplImage = nil;
|
|
dst: pIplImage = nil;
|
|
rot_mat: pCvMat = nil;
|
|
scale: double;
|
|
temp: pIplImage = nil;
|
|
center: TcvPoint2D32f;
|
|
|
|
begin
|
|
try
|
|
// Ďîëó÷ŕĺě ęŕđňčíęó (öâĺňíóţ)
|
|
src := cvLoadImage(filename, CV_LOAD_IMAGE_COLOR);
|
|
WriteLn(Format('[i] image: %s', [filename]));
|
|
|
|
// Âűâîäčě îđčăčíŕë
|
|
cvNamedWindow('Original', CV_WINDOW_AUTOSIZE);
|
|
cvShowImage('Original', src);
|
|
|
|
// Ďîâîđŕ÷čâŕĺě
|
|
// Ěŕňđčöŕ ňđŕíńôîđěŕöčč
|
|
rot_mat := cvCreateMat(2, 3, CV_32FC1);
|
|
// Âđŕůĺíčĺ îňíîńčňĺëüíî öĺíňđŕ čçîáđŕćĺíč˙
|
|
center.x := src^.width div 2;
|
|
center.y := src^.height div 2;
|
|
scale := 1;
|
|
cv2DRotationMatrix(center, 60, scale, rot_mat);
|
|
|
|
// Ńîçäŕĺě čçîáđŕćĺíčĺ
|
|
temp := cvCreateImage(cvSize(src^.width, src^.height), src^.depth, src^.nChannels);
|
|
|
|
// Âűďîëí˙ĺě âđŕůĺíčĺ
|
|
cvWarpAffine(src, temp, rot_mat, CV_INTER_LINEAR or CV_WARP_FILL_OUTLIERS, cvScalarAll(0));
|
|
|
|
// Ęîďčđóĺě čçîáđŕćĺíčĺ
|
|
cvCopy(temp, src);
|
|
|
|
// Îńâîáîćäŕĺě đĺńóđńű
|
|
cvReleaseImage(temp);
|
|
cvReleaseMat(rot_mat);
|
|
|
|
// Ďîęŕçűâŕĺě ÷ňî ďîëó÷čëîńü
|
|
cvNamedWindow('cvWarpAffine', CV_LOAD_IMAGE_GRAYSCALE);
|
|
cvShowImage('cvWarpAffine', src);
|
|
|
|
// Ćä¸ě íŕćŕňč˙ ęëŕâčřč
|
|
cvWaitKey(0);
|
|
|
|
// Îńâîáîćäŕĺě đĺńóđńű
|
|
cvReleaseImage(src);
|
|
cvReleaseImage(dst);
|
|
cvDestroyAllWindows();
|
|
except
|
|
on E: Exception do
|
|
WriteLn(E.ClassName, ': ', E.Message);
|
|
end;
|
|
|
|
end.
|