Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, iam implementig a program to load an image to picture box using open
FileDialog1
control and mark some points on that image. I was able to load the image to the pictureBox.I have declared a class called CvCreatePoints to mark points uisng CvPoint() function. But i dont know how to pass that pictureBox image to
CvCreatePoints
class.

Below is my code

In Form1.h Inside Button click event

C#
openFileDialog1->Filter = "Jpeg |*.Jpg";
                  openFileDialog1->FilterIndex = 1;
                    if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
                    {
                     pictureBox1->Image = Image::FromFile(openFileDialog1->FileName);
                    }



Then i have mouse_down event and there i tried to get the points when user clicks and pass them to the CvCreatePoints class. There i have a method called DrawPoints

CvCreatePoints cp;		 
 Point xy;
 xy = Control::MousePosition::get();
			 
 int xVal = xy.X;
 int yVal = xy.Y;
 cp.DrawPoints(pictureBox1->Image,xVal,yVal);


In my CvCreatePoints.h i have DrawPoints method

C#
CvCreatePoints(void);
    void DrawPoints(IplImage *img, int x,int y);



in CvCreatePoints.cpp class

C#
void CvCreatePoints::DrawPoints(IplImage *image, int x,int y)
{

}


When compiled,

cannot convert parameter 1 from 'System::Drawing::Image ^' to 'IplImage *'
error is given. So how do i cast
System::Drawing::Image to 'IplImage


Also

1>E:\Softwarez\OPENCV_DIR\Opencv243\build\include\opencv2/core/types_c.h(305): error C3862: 'cvRound': cannot compile an unmanaged function with /clr:pure or /clr:safe
1>          Inline native assembly not supported in managed code
1>E:\Softwarez\OPENCV_DIR\Opencv243\build\include\opencv2/core/types_c.h(305): error C3645: 'cvRound' : __clrcall cannot be used on functions compiled to native code
1>  MatlabToOpenCv.cpp
1>E:\Softwarez\OPENCV_DIR\Opencv243\build\include\opencv2/core/types_c.h(305): error C3862: 'cvRound': cannot compile an unmanaged function with /clr:pure or /clr:safe
1>          Inline native assembly not supported in managed code
1>E:\Softwarez\OPENCV_DIR\Opencv243\build\include\opencv2/core/types_c.h(305): error C3645: 'cvRound' : __clrcall cannot be used on functions compiled to native code


I don't understand this error :(
Thank you
Posted
Updated 25-Feb-13 0:08am
v2

1 solution

You cannot cast a CLR reference to a native pointer, the two things are not the same. And secondly you cannot call unmanaged code directly in a CLR program, you need to use the Platfrom Invoke[^] feature.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900