mirror of
https://github.com/Laex/Delphi-OpenCV.git
synced 2024-11-18 17:25:53 +01:00
48dbfc5c3f
+ FloodFill + Weighted + Weighted2 + cvInRange + SplitMerge + cvAnd + CvtPixToPlane + cvCopyMakeBorder + LoadAndTransformImage Signed-off-by: Laex <laex@bk.ru>
67 lines
1.4 KiB
ObjectPascal
67 lines
1.4 KiB
ObjectPascal
program ROI2;
|
|
|
|
{$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 = 'opencv_logo_with_text.png';
|
|
filename2 = '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.
|