2013-03-27 23:20:08 +01:00
|
|
|
|
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
|
|
|
|
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
|
|
|
|
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
|
|
|
|
program cv_SetImageROI2;
|
2013-01-01 13:29:34 +01:00
|
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
|
|
|
|
Core.types_c in '..\..\include\<5C>ore\Core.types_c.pas',
|
|
|
|
|
core_c in '..\..\include\<5C>ore\core_c.pas',
|
2013-03-27 23:20:08 +01:00
|
|
|
|
highgui_c in '..\..\include\highgui\highgui_c.pas',
|
|
|
|
|
LibName in '..\..\include\LibName.pas';
|
2013-01-01 13:29:34 +01:00
|
|
|
|
|
|
|
|
|
Const
|
|
|
|
|
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2013-03-27 23:20:08 +01:00
|
|
|
|
filename = 'Resource\opencv_logo_with_text.png';
|
|
|
|
|
filename2 = 'Resource\cat2.jpg';
|
2013-01-01 13:29:34 +01:00
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
image: PIplImage = nil;
|
|
|
|
|
src: PIplImage = nil;
|
|
|
|
|
x: Integer;
|
|
|
|
|
y: Integer;
|
|
|
|
|
width: Integer;
|
|
|
|
|
height: Integer;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
try
|
|
|
|
|
image := cvLoadImage(filename, 1);
|
|
|
|
|
|
|
|
|
|
Writeln('[i] image: ', filename);
|
|
|
|
|
if not Assigned(image) then
|
|
|
|
|
Halt;
|
|
|
|
|
cvNamedWindow('origianl', CV_WINDOW_AUTOSIZE);
|
|
|
|
|
cvNamedWindow('ROI', CV_WINDOW_AUTOSIZE);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ROI
|
|
|
|
|
x := 120;
|
|
|
|
|
y := 50;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
src := cvLoadImage(filename2, 1);
|
|
|
|
|
if not Assigned(src) then
|
|
|
|
|
Halt;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ROI
|
|
|
|
|
width := src^.width;
|
|
|
|
|
height := src^.height;
|
|
|
|
|
cvShowImage('origianl', image);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ROI
|
|
|
|
|
cvSetImageROI(image, cvRect(x, y, width, height));
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvZero(image);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvCopy(src, image);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ROI
|
|
|
|
|
cvResetImageROI(image);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvShowImage('ROI', image);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvWaitKey(0);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cvReleaseImage(image);
|
|
|
|
|
cvReleaseImage(src);
|
|
|
|
|
cvDestroyAllWindows;
|
|
|
|
|
except
|
|
|
|
|
on E: Exception do
|
|
|
|
|
Writeln(E.ClassName, ': ', E.Message);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|