mirror of
https://github.com/Laex/Delphi-OpenCV.git
synced 2024-11-17 00:35:54 +01:00
42 lines
1.1 KiB
ObjectPascal
42 lines
1.1 KiB
ObjectPascal
|
program LoadAndTransformImage;
|
|||
|
|
|||
|
{$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',
|
|||
|
imgproc.types_c in '..\..\include\imgproc\imgproc.types_c.pas',
|
|||
|
imgproc_c in '..\..\include\imgproc\imgproc_c.pas';
|
|||
|
|
|||
|
Const
|
|||
|
filename = 'opencv_logo_with_text.png';
|
|||
|
filename_gray = 'opencv_logo_with_text_gray.png';
|
|||
|
|
|||
|
Var
|
|||
|
image: pIplImage = nil;
|
|||
|
gray_image: pIplImage = nil;
|
|||
|
|
|||
|
begin
|
|||
|
try
|
|||
|
image := cvLoadImage(filename, 1);
|
|||
|
gray_image := cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);
|
|||
|
cvCvtColor(image, gray_image, CV_RGB2GRAY);
|
|||
|
cvSaveImage(filename_gray, gray_image);
|
|||
|
cvNamedWindow(filename, CV_WINDOW_AUTOSIZE);
|
|||
|
cvNamedWindow('Gray image', CV_WINDOW_AUTOSIZE);
|
|||
|
cvShowImage(filename, image);
|
|||
|
cvShowImage('Gray image', gray_image);
|
|||
|
cvWaitKey(0);
|
|||
|
cvReleaseImage(image);
|
|||
|
cvReleaseImage(gray_image);
|
|||
|
cvDestroyAllWindows;
|
|||
|
except
|
|||
|
on E: Exception do
|
|||
|
Writeln(E.ClassName, ': ', E.Message);
|
|||
|
end;
|
|||
|
|
|||
|
end.
|