Difference between revisions of "Hello World in C++"
Line 1: | Line 1: | ||
− | <font color=green>''' This project is part of the Emgu.CV.Example solution''' | + | ---- |
+ | <div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;"> | ||
+ | ---- | ||
+ | =[http://isiqilujev.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]= | ||
+ | ---- | ||
+ | =[http://isiqilujev.co.cc CLICK HERE]= | ||
+ | ---- | ||
+ | </div> | ||
+ | <font color=green>''' This project is part of the Emgu.CV.Example solution'''</font> | ||
== System Requirement == | == System Requirement == | ||
Line 12: | Line 20: | ||
== Source Code == | == Source Code == | ||
− | + | <source lang=cpp> | |
− | array | + | array<Image<Bgr^, Byte>^>^ ImageProcessor::ProcessImage() |
{ | { | ||
//---- plain old Open CV code ---- | //---- plain old Open CV code ---- | ||
Line 19: | Line 27: | ||
cvSet(img1, cvScalar(255, 255, 255)); | cvSet(img1, cvScalar(255, 255, 255)); | ||
CvFont font; | CvFont font; | ||
− | cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0); | + | cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0); |
− | cvPutText(img1, "Hello, World", cvPoint(50, 100), &font, cvScalar(0.0, 0.0, 0.0)); | + | cvPutText(img1, "Hello, World", cvPoint(50, 100), &font, cvScalar(0.0, 0.0, 0.0)); |
//---- end of plain old OpenCV code | //---- end of plain old OpenCV code | ||
//create the managed Emgu::CV::Image array | //create the managed Emgu::CV::Image array | ||
− | array | + | array<Image<Bgr^, Byte>^>^ imageArray = gcnew array<Image<Bgr^, Byte>^>(2); |
//---- Copying image from IplImage to Emgu::CV::Image class | //---- Copying image from IplImage to Emgu::CV::Image class | ||
//create a managed Image of the same size, this image will be displayed on the LHS of the GUI | //create a managed Image of the same size, this image will be displayed on the LHS of the GUI | ||
− | imageArray[0] = gcnew Image | + | imageArray[0] = gcnew Image<Bgr^, Byte>(img1->width, img1->height); |
//copy the image from unmanaged IplImage to the managed image | //copy the image from unmanaged IplImage to the managed image | ||
cvCopy(img1, imageArray[0]->Ptr.ToPointer()); | cvCopy(img1, imageArray[0]->Ptr.ToPointer()); | ||
Line 34: | Line 42: | ||
//---- Release the Unmanaged IplImage ---- | //---- Release the Unmanaged IplImage ---- | ||
− | cvReleaseImage(&img1); | + | cvReleaseImage(&img1); |
//---- Image Processing in EmguCV using .Net Syntax | //---- Image Processing in EmguCV using .Net Syntax | ||
//another image to be displayed on the RHS of the GUI | //another image to be displayed on the RHS of the GUI | ||
− | imageArray[1] = gcnew Image | + | imageArray[1] = gcnew Image<Bgr^, Byte>(imageArray[0]->Width, imageArray[0]->Height); |
//fill the image with random colors of mean 50 and standard deviation of 10; | //fill the image with random colors of mean 50 and standard deviation of 10; | ||
imageArray[1]->SetRandNormal(MCvScalar(50.0, 50.0, 50.0), MCvScalar(10.0, 10.0, 10.0)); | imageArray[1]->SetRandNormal(MCvScalar(50.0, 50.0, 50.0), MCvScalar(10.0, 10.0, 10.0)); | ||
Line 46: | Line 54: | ||
return imageArray; | return imageArray; | ||
} | } | ||
− | + | </source> | |
== Result == | == Result == | ||
[[image:cplusplusExample.png|300px|center|thumb|Result of C++ Example]] | [[image:cplusplusExample.png|300px|center|thumb|Result of C++ Example]] |
Revision as of 03:32, 24 November 2010
<font color=green> This project is part of the Emgu.CV.Example solution</font>
System Requirement
Component | Requirement | Detail |
---|---|---|
Emgu CV | Version 2.0.0.0 Alpha | |
Operation System | Windows Only | Mono cannot compile managed C++ |
Source Code
<source lang=cpp> array<Image<Bgr^, Byte>^>^ ImageProcessor::ProcessImage() {
//---- plain old Open CV code ----
IplImage* img1 = cvCreateImage(cvSize(300, 200), IPL_DEPTH_8U, 3); cvSet(img1, cvScalar(255, 255, 255)); CvFont font; cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0); cvPutText(img1, "Hello, World", cvPoint(50, 100), &font, cvScalar(0.0, 0.0, 0.0)); //---- end of plain old OpenCV code
//create the managed Emgu::CV::Image array array<Image<Bgr^, Byte>^>^ imageArray = gcnew array<Image<Bgr^, Byte>^>(2);
//---- Copying image from IplImage to Emgu::CV::Image class //create a managed Image of the same size, this image will be displayed on the LHS of the GUI imageArray[0] = gcnew Image<Bgr^, Byte>(img1->width, img1->height); //copy the image from unmanaged IplImage to the managed image cvCopy(img1, imageArray[0]->Ptr.ToPointer()); //---- End of image copying
//---- Release the Unmanaged IplImage ---- cvReleaseImage(&img1);
//---- Image Processing in EmguCV using .Net Syntax //another image to be displayed on the RHS of the GUI imageArray[1] = gcnew Image<Bgr^, Byte>(imageArray[0]->Width, imageArray[0]->Height); //fill the image with random colors of mean 50 and standard deviation of 10; imageArray[1]->SetRandNormal(MCvScalar(50.0, 50.0, 50.0), MCvScalar(10.0, 10.0, 10.0)); imageArray[1] = imageArray[0] - imageArray[1]; //add the noise to the image //---- End of Image Processing in Emgu CV.
return imageArray; } </source>