Click here to Skip to main content
12,244,322 members (49,227 online)
Rate this:
 
Please Sign up or sign in to vote.
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

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

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


in CvCreatePoints.cpp class

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 Frown | :(
Thank you
Posted 25-Feb-13 1:07am
Edited 25-Feb-13 1:08am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100