Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

opencv in windows form

I am using now windows form in visual c++. I got an error:

error C2065: 'Filename' : undeclared identifier

error C2065: 'openFileDialog1' : undeclared identifier

error C2227: left of '->FileName' must point to class/struct/union/generic type

I don't know what is wrong in my code. Anyone who can solve this problem?

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            cv::Mat img;

            OpenFileDialog ^SelectFileDialog = gcnew OpenFileDialog();

            SelectFileDialog->Filter = "All Files (*.*)|*.*";
            Filename = SelectFileDialog->FileName;

            img = cv::imread(openFileDialog1->FileName, CV_LOAD_IMAGE_COLOR);


            System::Drawing::Graphics^ graphics = pictureBox1->CreateGraphics();
            System::IntPtr ptr(img.ptr());
            System::Drawing::Bitmap^ b  = gcnew System::Drawing::Bitmap(img.cols,img.rows,img.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb,ptr);
            System::Drawing::RectangleF rect(0,0,pictureBox1->Width,pictureBox1->Height);
            graphics->DrawImage(b,rect);


         }

opencv in windows form

I am using now windows form in visual c++. I got an error:

error C2065: 'Filename' : undeclared identifier

error C2065: 'openFileDialog1' : undeclared identifier

error C2227: left of '->FileName' must point to class/struct/union/generic type

I don't know what is wrong in my code. Anyone who can solve this problem?

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            cv::Mat img;

            OpenFileDialog ^SelectFileDialog = gcnew OpenFileDialog();

            SelectFileDialog->Filter = "All Files (*.*)|*.*";
            Filename = SelectFileDialog->FileName;

            img = cv::imread(openFileDialog1->FileName, CV_LOAD_IMAGE_COLOR);

             System::Drawing::Graphics^ graphics = pictureBox1->CreateGraphics();
            System::IntPtr ptr(img.ptr());
            System::Drawing::Bitmap^ b  = gcnew System::Drawing::Bitmap(img.cols,img.rows,img.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb,ptr);
            System::Drawing::RectangleF rect(0,0,pictureBox1->Width,pictureBox1->Height);
            graphics->DrawImage(b,rect);


         }
click to hide/show revision 3
hi there, please don't use hash signs with tags, as it leads to annoying duplicates. thank you!

updated 2013-09-04 01:55:55 -0600

berak gravatar image

opencv in windows form

I am using now windows form in visual c++. I got an error:

error C2065: 'Filename' : undeclared identifier

error C2065: 'openFileDialog1' : undeclared identifier

error C2227: left of '->FileName' must point to class/struct/union/generic type

I don't know what is wrong in my code. Anyone who can solve this problem?

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            cv::Mat img;

            img = cv::imread(openFileDialog1->FileName, CV_LOAD_IMAGE_COLOR);

            System::Drawing::Graphics^ graphics = pictureBox1->CreateGraphics();
            System::IntPtr ptr(img.ptr());
            System::Drawing::Bitmap^ b  = gcnew System::Drawing::Bitmap(img.cols,img.rows,img.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb,ptr);
            System::Drawing::RectangleF rect(0,0,pictureBox1->Width,pictureBox1->Height);
            graphics->DrawImage(b,rect);


         }