Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ VS2010 OpenCV
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 0:07am
Edited 25-Feb-13 0: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
0 OriginalGriff 259
1 Sergey Alexandrovich Kryukov 182
2 Hard_Rockz 153
3 Richard MacCutchan 125
4 Maciej Los 104
0 OriginalGriff 5,374
1 Sergey Alexandrovich Kryukov 4,713
2 Peter Leow 2,944
3 DamithSL 2,465
4 Maciej Los 2,270


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