mirror of
https://github.com/Laex/Delphi-OpenCV.git
synced 2024-11-16 08:15:52 +01:00
43aca9437b
[+] cvGetSubRect [*] Changed the names of the projects Signed-off-by: Laex <laex@bk.ru>
71 lines
1.6 KiB
ObjectPascal
71 lines
1.6 KiB
ObjectPascal
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
|
|
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
|
|
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
|
|
program cv_SetImageROI2;
|
|
|
|
{$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',
|
|
LibName in '..\..\include\LibName.pas';
|
|
|
|
Const
|
|
// èìÿ êàðòèíêè
|
|
filename = 'Resource\opencv_logo_with_text.png';
|
|
filename2 = 'Resource\cat2.jpg';
|
|
|
|
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);
|
|
// çàäà¸ì ROI
|
|
x := 120;
|
|
y := 50;
|
|
// äîáàâî÷íîå èçîáðàæåíèå
|
|
src := cvLoadImage(filename2, 1);
|
|
if not Assigned(src) then
|
|
Halt;
|
|
// ðàçìåð ROI
|
|
width := src^.width;
|
|
height := src^.height;
|
|
cvShowImage('origianl', image);
|
|
// óñòàíàâëèâàåì ROI
|
|
cvSetImageROI(image, cvRect(x, y, width, height));
|
|
// îáíóëèì èçîáðàæåíèå
|
|
cvZero(image);
|
|
// êîïèðóåì èçîáðàæåíèå
|
|
cvCopy(src, image);
|
|
// ñáðàñûâàåì ROI
|
|
cvResetImageROI(image);
|
|
// ïîêàçûâàåì èçîáðàæåíèå
|
|
cvShowImage('ROI', image);
|
|
// æä¸ì íàæàòèÿ êëàâèøè
|
|
cvWaitKey(0);
|
|
// îñâîáîæäàåì ðåñóðñû
|
|
cvReleaseImage(image);
|
|
cvReleaseImage(src);
|
|
cvDestroyAllWindows;
|
|
except
|
|
on E: Exception do
|
|
Writeln(E.ClassName, ': ', E.Message);
|
|
end;
|
|
|
|
end.
|