Delphi-OpenCV/samples/LibTest/cvSetImageROI/cv_SetImageROI.dpr

68 lines
1.4 KiB
ObjectPascal
Raw Normal View History

// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
program cv_SetImageROI;
{$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',
highgui_c in '..\..\..\include\highgui\highgui_c.pas',
uLibName in '..\..\..\include\uLibName.pas',
types_c in '..\..\..\include\<5C>ore\types_c.pas';
Const
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
filename = 'Resource\cat2.jpg';
var
image: PIplImage = nil;
x: Integer;
y: Integer;
width: Integer;
height: Integer;
add: 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 := 140;
y := 120;
width := 200;
height := 200;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
add := 200;
cvShowImage('origianl', image);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ROI
cvSetImageROI(image, cvRect(x, y, width, height));
cvAddS(image, cvScalar(add), 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);
cvDestroyAllWindows;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.