Delphi-OpenCV/2.4.3/samples/ROI/ROI.dpr
Laex 48dbfc5c3f Add samples:
+ FloodFill
+ Weighted
+ Weighted2
+ cvInRange
+ SplitMerge
+ cvAnd
+ CvtPixToPlane
+ cvCopyMakeBorder
+ LoadAndTransformImage

Signed-off-by: Laex <laex@bk.ru>
2013-01-02 01:36:38 +04:00

63 lines
1.2 KiB
ObjectPascal

program ROI;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Core.types_c in '..\..\include\ñore\Core.types_c.pas',
core_c in '..\..\include\ñore\core_c.pas',
highgui_c in '..\..\include\highgui\highgui_c.pas';
Const
// èìÿ êàðòèíêè
filename = '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);
// çàäà¸ì ROI
x := 140;
y := 120;
width := 200;
height := 200;
// äîáàâî÷íàÿ âåëè÷èíà
add := 200;
cvShowImage('origianl', image);
// óñòàíàâëèâàåì ROI
cvSetImageROI(image, cvRect(x, y, width, height));
cvAddS(image, cvScalar(add), image);
// ñáðàñûâàåì ROI
cvResetImageROI(image);
// ïîêàçûâàåì èçîáðàæåíèå
cvShowImage('ROI', image);
// æä¸ì íàæàòèÿ êëàâèøè
cvWaitKey(0);
// îñâîáîæäàåì ðåñóðñû
cvReleaseImage(image);
cvDestroyAllWindows;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.