将opencv链接到Visual Studio窗口形成应用程序

时间:2013-10-15 07:51:24

标签: c++ visual-studio-2010 opencv

我正在尝试将opencv链接到Windows Form应用程序VS 2010.我正在使用教程

http://linkopencvtovs.blogspot.com/2013/10/how-to-link-opencv-to-microsoft-visual.html

它适用于控制台应用程序,但它不允许我在基于GUI的程序中使用opencv的任何功能..在下面给出错误..

错误1错误C2065:'IplImage':未声明的标识符c:\ users \ ayesha \ documents \ visual studio 2010 \ projects \ abc \ abc \ Form1.h 130 1 abc 错误2错误C3861:'cvLoadImage':找不到标识符c:\ users \ ayesha \ documents \ visual studio 2010 \ projects \ abc \ abc \ Form1.h 130 1 abc

代码是简单的GUI

pragma一次

namespace abc {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;


/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
    Form1(void)
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
    }

    protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~Form1()
    {
        if (components)
        {
            delete components;
        }
    }
    private: System::Windows::Forms::Button^  button1;
private: System::Windows::Forms::TextBox^  path;
private: System::Windows::Forms::Button^  summary;
protected: 


    private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;

    #pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
        this->button1 = (gcnew System::Windows::Forms::Button());
        this->path = (gcnew System::Windows::Forms::TextBox());
        this->summary = (gcnew System::Windows::Forms::Button());
        this->SuspendLayout();
        // 
        // button1
        // 
        this->button1->Location = System::Drawing::Point(392, 68);
        this->button1->Name = L"button1";
        this->button1->Size = System::Drawing::Size(75, 23);
        this->button1->TabIndex = 0;
        this->button1->Text = L"browse";
        this->button1->UseVisualStyleBackColor = true;
        this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
        // 
        // path
        // 
        this->path->Location = System::Drawing::Point(23, 68);
        this->path->Name = L"path";
        this->path->Size = System::Drawing::Size(304, 20);
        this->path->TabIndex = 1;
        // 
        // summary
        // 
        this->summary->Location = System::Drawing::Point(153, 156);
        this->summary->Name = L"summary";
        this->summary->Size = System::Drawing::Size(159, 27);
        this->summary->TabIndex = 2;
        this->summary->Text = L"summaize video";
        this->summary->UseVisualStyleBackColor = true;
        this->summary->Click += gcnew System::EventHandler(this, &Form1::summary_Click);
        // 
        // Form1
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(556, 262);
        this->Controls->Add(this->summary);
        this->Controls->Add(this->path);
        this->Controls->Add(this->button1);
        this->Name = L"Form1";
        this->Text = L"Form1";
        this->ResumeLayout(false);
        this->PerformLayout();

    }

pragma endregion

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    Stream^ myStream;
    OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;

    openFileDialog1->InitialDirectory = "c:\\";
    openFileDialog1->Filter = "txt files (*.avi)|*.avi|All files (*.*)|*.*";
    openFileDialog1->FilterIndex = 2;
    openFileDialog1->RestoreDirectory = true;

    if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
    {
        if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
        {
            path->Text = Convert::ToString(openFileDialog1->FileName);

            // Insert code to read the stream here.
            String ^ temp = "you have successfully browsed a video";
            System::Windows::Forms::MessageBox::Show(temp);

            myStream->Close();
        }
    }
}

private:System :: Void summary_Click(System :: Object ^ sender,System :: EventArgs ^ e){              IplImage * img = cvLoadImage(“dss”);          } }; }

0 个答案:

没有答案