C++ cli makePtr不';不行? menuStrip1=(gcnewsystem::Windows::Forms::MenuStrip()); 此->文件ToolStripMenuItem=(gcnew System::Windows::Forms::T

C++ cli makePtr不';不行? menuStrip1=(gcnewsystem::Windows::Forms::MenuStrip()); 此->文件ToolStripMenuItem=(gcnew System::Windows::Forms::T,c++-cli,opencv3.0,C++ Cli,Opencv3.0,makePtr不';不行? menuStrip1=(gcnewsystem::Windows::Forms::MenuStrip()); 此->文件ToolStripMenuItem=(gcnew System::Windows::Forms::ToolStripMenuItem()); 此->loadImageToolStripMenuItem=(gcnew System::Windows::Forms::ToolStripMenuItem()); 此->saveImageToolSt

makePtr不';不行? <我是C++和OpenCV的新手,现在我正在尝试在VisualStudio 2013上使用Windows窗体应用程序。这是我的密码:

#include <opencv2/opencv.hpp>
#include <opencv2/opencv_modules.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/stitching/detail/blenders.hpp>
#include <opencv2/stitching/detail/camera.hpp>
#include <opencv2/stitching/detail/exposure_compensate.hpp>
#include <opencv2/stitching/detail/matchers.hpp>
#include <opencv2/stitching/detail/motion_estimators.hpp>
#include <opencv2/stitching/detail/seam_finders.hpp>
#include <opencv2/stitching/detail/util.hpp>
#include <opencv2/stitching/detail/warpers.hpp>
#include <opencv2/stitching/warpers.hpp>

#include <iostream>
#include <string>
#include <vector>

#pragma once

namespace Stitch {

    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 MyForm
    /// </summary>
    public ref class MyForm : public System::Windows::Forms::Form
    {
    public :
        std::vector<cv::Mat> *gbr_arr;
        array<System::String^>^ dir_arr;
        cv::Mat *hasil_gbr;
        int jml_gbr;

        MyForm(void)
        {
            InitializeComponent();
            gbr_arr = new std::vector<cv::Mat>;
            //
            //TODO: Add the constructor code here
            //
        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~MyForm()
        {
            if (components)
            {
                delete components;
            }
        }

    private: System::Windows::Forms::MenuStrip^  menuStrip1;
    protected:
    private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
    private: System::Windows::Forms::ToolStripMenuItem^  loadImageToolStripMenuItem;
    private: System::Windows::Forms::ToolStripMenuItem^  saveImageToolStripMenuItem;
    private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator1;
    private: System::Windows::Forms::ToolStripMenuItem^  closeToolStripMenuItem;
    private: System::Windows::Forms::ToolStripMenuItem^  aboutToolStripMenuItem;
    private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
    private: System::Windows::Forms::SaveFileDialog^  saveFileDialog1;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::ProgressBar^  progressBar1;
    private: System::Windows::Forms::Panel^  panel1;
    private: System::ComponentModel::BackgroundWorker^  backgroundWorker1;
    private: System::Windows::Forms::Label^  label1;




    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->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
            this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->loadImageToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->saveImageToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
            this->closeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
            this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
            this->panel1 = (gcnew System::Windows::Forms::Panel());
            this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->menuStrip1->SuspendLayout();
            this->SuspendLayout();
            // 
            // menuStrip1
            // 
            this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {
                this->fileToolStripMenuItem,
                    this->aboutToolStripMenuItem
            });
            this->menuStrip1->Location = System::Drawing::Point(0, 0);
            this->menuStrip1->Name = L"menuStrip1";
            this->menuStrip1->Size = System::Drawing::Size(829, 24);
            this->menuStrip1->TabIndex = 0;
            this->menuStrip1->Text = L"menuStrip1";
            // 
            // fileToolStripMenuItem
            // 
            this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {
                this->loadImageToolStripMenuItem,
                    this->saveImageToolStripMenuItem, this->toolStripSeparator1, this->closeToolStripMenuItem
            });
            this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
            this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20);
            this->fileToolStripMenuItem->Text = L"File";
            // 
            // loadImageToolStripMenuItem
            // 
            this->loadImageToolStripMenuItem->Name = L"loadImageToolStripMenuItem";
            this->loadImageToolStripMenuItem->Size = System::Drawing::Size(136, 22);
            this->loadImageToolStripMenuItem->Text = L"Load Image";
            this->loadImageToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::loadImageToolStripMenuItem_Click);
            // 
            // saveImageToolStripMenuItem
            // 
            this->saveImageToolStripMenuItem->Name = L"saveImageToolStripMenuItem";
            this->saveImageToolStripMenuItem->Size = System::Drawing::Size(136, 22);
            this->saveImageToolStripMenuItem->Text = L"Save Image";
            this->saveImageToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::saveImageToolStripMenuItem_Click);
            // 
            // toolStripSeparator1
            // 
            this->toolStripSeparator1->Name = L"toolStripSeparator1";
            this->toolStripSeparator1->Size = System::Drawing::Size(133, 6);
            // 
            // closeToolStripMenuItem
            // 
            this->closeToolStripMenuItem->Name = L"closeToolStripMenuItem";
            this->closeToolStripMenuItem->Size = System::Drawing::Size(136, 22);
            this->closeToolStripMenuItem->Text = L"Close";
            this->closeToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::closeToolStripMenuItem_Click);
            // 
            // aboutToolStripMenuItem
            // 
            this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem";
            this->aboutToolStripMenuItem->Size = System::Drawing::Size(52, 20);
            this->aboutToolStripMenuItem->Text = L"About";
            // 
            // openFileDialog1
            // 
            this->openFileDialog1->Filter = L"JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|All Files (*.*)|*.*";
            this->openFileDialog1->FilterIndex = 3;
            this->openFileDialog1->InitialDirectory = L"E:\\\\Gambar";
            this->openFileDialog1->Multiselect = true;
            this->openFileDialog1->RestoreDirectory = true;
            // 
            // button1
            // 
            this->button1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
            this->button1->Location = System::Drawing::Point(717, 293);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(100, 23);
            this->button1->TabIndex = 1;
            this->button1->Text = L"Process";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
            // 
            // progressBar1
            // 
            this->progressBar1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left)
                | System::Windows::Forms::AnchorStyles::Right));
            this->progressBar1->Location = System::Drawing::Point(0, 322);
            this->progressBar1->Name = L"progressBar1";
            this->progressBar1->Size = System::Drawing::Size(829, 23);
            this->progressBar1->TabIndex = 2;
            // 
            // panel1
            // 
            this->panel1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
                | System::Windows::Forms::AnchorStyles::Left)
                | System::Windows::Forms::AnchorStyles::Right));
            this->panel1->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
            this->panel1->BackColor = System::Drawing::SystemColors::ControlLightLight;
            this->panel1->Location = System::Drawing::Point(0, 27);
            this->panel1->Name = L"panel1";
            this->panel1->Size = System::Drawing::Size(829, 260);
            this->panel1->TabIndex = 3;
            // 
            // backgroundWorker1
            // 
            this->backgroundWorker1->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &MyForm::backgroundWorker1_DoWork);
            // 
            // label1
            // 
            this->label1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(12, 298);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(0, 13);
            this->label1->TabIndex = 4;
            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(829, 345);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->panel1);
            this->Controls->Add(this->progressBar1);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->menuStrip1);
            this->MainMenuStrip = this->menuStrip1;
            this->Name = L"MyForm";
            this->Text = L"Stitcher";
            this->WindowState = System::Windows::Forms::FormWindowState::Maximized;
            this->menuStrip1->ResumeLayout(false);
            this->menuStrip1->PerformLayout();
            this->ResumeLayout(false);
            this->PerformLayout();

        }

        void MarshalString(System::String ^ s, cv::String& os) {
            using namespace Runtime::InteropServices;
            const char* chars =
                (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer();
            os = chars;
            Marshal::FreeHGlobal(IntPtr((void*)chars));
        }

#pragma endregion
    private: System::Void loadImageToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
        using namespace Runtime::InteropServices;

        panel1->AutoScroll = true;
        panel1->Controls->Clear();

        int x = 20;
        int y = 20;
        int maxHeight = -1;

        if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
        {
            dir_arr = openFileDialog1->FileNames;
            gbr_arr->clear();

            for each (System::String^ gbr in dir_arr)
            {
                cv::String nama_gbr;
                MarshalString(gbr, nama_gbr);
                cv::Mat gambar = imread(nama_gbr);
                gbr_arr->push_back(gambar);

                PictureBox^ pic = gcnew PictureBox;
                pic->Width = 0.3*(gambar.cols); pic->Height = 0.3*(gambar.rows);
                pic->SizeMode = PictureBoxSizeMode::StretchImage;
                pic->Image = System::Drawing::Image::FromFile(gbr);
                pic->Location = System::Drawing::Point(x, y);
                x += pic->Width + 10;
                maxHeight = Math::Max(pic->Height, maxHeight);
                if (x > this->panel1->Width)
                {
                    x = 20;
                    y += pic->Height + 10;
                }
                this->panel1->Controls->Add(pic);
            }

            jml_gbr = static_cast<int> (gbr_arr->size());
        }
    }

    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
        label1->Controls->Clear();
        label1->Text = "Stitching...";
        panel1->Controls->Clear();
        backgroundWorker1->RunWorkerAsync(1);
    }

    private: System::Void saveImageToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
        if (saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
        {

        }
    }

    private: System::Void closeToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
            Application::Exit();
    }

    private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {  
        cv::Ptr<cv::detail::FeaturesFinder> finder;
        finder = cv::makePtr<cv::detail::SurfFeaturesFinder>();

        std::vector<cv::detail::ImageFeatures> feature(jml_gbr);
        std::vector<cv::detail::MatchesInfo> pairwise_matching;

        for (int i = 0; i < jml_gbr; i++)
        {
            cv::Mat key;
            (*finder) (gbr_arr[i], feature[i]);
            feature[i].img_idx = i;

            cv::drawKeypoints(gbr_arr[i], feature[i].keypoints, key, cv::Scalar::all(-1), 4);
            cv::namedWindow("KeyPoints", CV_WINDOW_KEEPRATIO);
            cv::imshow("KeyPoints", gbr_arr[i]);

            cv::waitKey(0);
            MessageBox::Show("Hello!");
        }

        finder->collectGarbage();

        cv::detail::BestOf2NearestMatcher matcher(false, 0.65);
        matcher(feature, pairwise_matching);

        matcher.collectGarbage();


    }

    };
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#布拉格语一次
命名空间缝合{
使用名称空间系统;
使用名称空间System::ComponentModel;
使用名称空间系统::集合;
使用命名空间System::Windows::Forms;
使用名称空间System::Data;
使用名称空间系统::绘图;
使用名称空间系统::IO;
/// 
///我的表格摘要
/// 
公共引用类MyForm:public System::Windows::Forms::Form
{
公众:
标准::向量*gbr\u arr;
数组^dir\u arr;
cv::Mat*hasil_gbr;
int jml_gbr;
我的表格(作废)
{
初始化组件();
gbr_arr=新的标准::向量;
//
//TODO:在此处添加构造函数代码
//
}
受保护的:
/// 
///清理所有正在使用的资源。
/// 
~MyForm()
{
if(组件)
{
删除组件;
}
}
private:System::Windows::Forms::MenuStrip^menuStrip1;
受保护的:
私有:系统::Windows::窗体::ToolStripMenuItem ^fileToolStripMenuItem;
私有:系统::Windows::窗体::ToolStripMenuItem^loadImageToolStripMenuItem;
私有:系统::Windows::窗体::ToolStripMenuItem^saveImageToolStripMenuItem;
私有:系统::Windows::窗体::ToolStripSeparator^ToolStripSeparator 1;
私有:系统::Windows::窗体::ToolStripMenuItem^closeToolStripMenuItem;
私有:系统::Windows::窗体::ToolStripMenuItem^关于ToolStripMenuItem;
私有:系统::Windows::窗体::OpenFileDialog^openFileDialog1;
private:System::Windows::Forms::SaveFileDialog^saveFileDialog1;
私有:系统::Windows::窗体::按钮^button1;
私有:系统::Windows::窗体::ProgressBar^progressBar1;
私有:系统::Windows::窗体::面板^panel1;
私有:System::ComponentModel::BackgroundWorker^backgroundWorker1;
私有:系统::Windows::窗体::标签^label1;
私人:
/// 
///必需的设计器变量。
/// 
系统::组件模型::容器^组件;
#pragma区域Windows窗体设计器生成的代码
/// 
///设计器支持所需的方法-不修改
///此方法的内容与代码编辑器一起使用。
/// 
void初始化组件(void)
{
这->menuStrip1=(gcnewsystem::Windows::Forms::MenuStrip());
此->文件ToolStripMenuItem=(gcnew System::Windows::Forms::ToolStripMenuItem());
此->loadImageToolStripMenuItem=(gcnew System::Windows::Forms::ToolStripMenuItem());
此->saveImageToolStripMenuItem=(gcnew System::Windows::Forms::ToolStripMenuItem());
这->toolStripSeparator1=(gcnew System::Windows::Forms::ToolStripSeparator());
此->closeToolStripMenuItem=(gcnew System::Windows::Forms::ToolStripMenuItem());
这->关于ToolStripMenuItem=(gcnew System::Windows::Forms::ToolStripMenuItem());
这->openFileDialog1=(gcnew System::Windows::Forms::OpenFileDialog());
这->saveFileDialog1=(gcnew System::Windows::Forms::SaveFileDialog());
此->按钮1=(gcnew System::Windows::Forms::Button());
这->progressBar1=(gcnew System::Windows::Forms::ProgressBar());
这->panel1=(gcnewsystem::Windows::Forms::Panel());
这->backgroundWorker1=(gcnew System::ComponentModel::BackgroundWorker());
这->标签1=(gcnewsystem::Windows::Forms::Label());
此->菜单提示1->SuspendLayout();
此->SuspendLayout();
// 
//菜单第1条
// 
此->菜单项->项目->添加范围(gcnew cli::array(2){
此->文件工具条带菜单项,
此->关于ToolStripMenuItem
});
此->菜单提示1->位置=系统::图形::点(0,0);
此->menuStrip1->Name=L“menuStrip1”;
这->菜单提示1->尺寸=系统::图纸::尺寸(829,24);
此->菜单列表1->选项卡索引=0;
此->菜单列表1->文本=L“菜单列表1”;
// 
//fileToolStripMenuItem
// 
此->文件工具条带菜单项->下拉项->添加范围(gcnew cli::array(4){
此->loadImageToolStripMenuItem,
此->保存图像工具条带菜单项,此->工具条带分隔符1,此->关闭工具条带菜单项
});
此->fileToolStripMenuItem->Name=L“fileToolStripMenuItem”;
此->文件工具条带菜单项->大小=系统::绘图::大小(37,20);
此->文件工具条带菜单项->文本=L“文件”;
// 
//loadImageToolStripMenuItem
// 
此->loadImageToolStripMenuItem->Name=L“loadImageToolStripMenuItem”;
此->loadImageToolStripMenuItem->大小=系统::绘图::大小(136,22);
此->loadImageToolStripMenuItem->Text=L“加载图像”;
this->loadImageToolStripMenuItem->Click+=gcnew System::EventHandler(this,&MyForm::loadImageToolStripMenuItem\u Click);
// 
//saveImageToolStripMenuItem
// 
此->saveImageToolStripMenuItem->Name=L“saveImageToolStripMenuItem”;
此->saveImageToolStripMenuItem->大小=系统::绘图::大小(136,22);
此->保存图像工具条带菜单项->文本=L“保存图像”;
此->saveImageToolStripMenuItem->单击+=gcnew System::EventHandler(此,&MyForm::saveImageToolStripMe
finder = cv::makePtr<cv::detail::SurfFeaturesFinder>();