"ZW Edition Delphi and Halcon Series Original Tutorial" Thoperatorsetx Edition HELLO,ZW
The following is an introduction to the V3 version of HELLO,ZW.
Halcon two core controls, Thimagex, Thoperatorsetx controls.
Thimagex controls are highly efficient and can be considered internal data exchange patterns, but differ from the standard Halcon functions and are recommended for experienced users.
Thoperatorsetx control, using a similar simulation mode, to the Halcon module to provide script instructions, processed by the Halcon system, generate the result data, and then back to Delphi, C and other development systems. Instructions are fully consistent with Halcon for beginners to master.
We've learned about the Thimagex control, and now we'll show you how to use the Thoperatorsetx control and write: HELLO,ZW
Typically tutorials, thoperatorsetx controls, are used in conjunction with THWINDOWX visual controls.
But thwindowx need to initialize, configuration, for beginners, not very suitable, moreover, for analysis, the results are mainly output image files, all of us still use image file mode.
The full code is as follows:
1 procedurehello_zw03 ();2 var3 Xset:thoperatorsetx;4 Img,img2:ihuntypedobjectx;5 w,h:olevariant;6 begin7Xset:=thoperatorsetx.create (Nil);8 withMwin Do begin9Xset.readimage (IMG,'Tmp\hello_zw24.png');Ten xset.getimagesize (IMG, W, h); One A Xset. Rgb1togray (IMG,IMG2); -Xset.writeimage (Img2,'PNG',0,'Tmp\hello_zw30.png') - End; the Freeandnil(xset); - //Freeandnil (IMG); Freeandnil (IMG2); Unable to release IMG memory - //img. Dispose ();//c# has Dispose release method, Delphi version has no - End;
Because it was the V3 version of Hello, I made some enhancements.
"Source Code description"
Line 10th, Xset.getimagesize (IMG, W, h);
Get image width W, height h Note that variables W, h, must be of type Olevariant, Variant, or integer.
Line 12th, Xset. Rgb1togray (IMG,IMG2);
Image transform, convert my grayscale image
16th, 17 lines, release the memory of the IMG variable, error, very strange, so with the comment
//freeandnil (IMG); Freeandnil (IMG2); Unable to release IMG memory
//img. Dispose ();//c# has Dispose release method, Delphi version has no
C, C # version of the image control has . Dispose method, free memory, Delphi version No,
Strange, is it automatic release, or this is the main culprit of the Delphi version of memory leaks
Have time, with professional memory analysis software, check
"ZW Edition Delphi and Halcon Series original tutorial", URL, cnblogs.com/ziwang/"
"ZW Edition Delphi and Halcon Series Original Tutorial" Thoperatorsetx Edition HELLO,ZW