【问题标题】:Native' has exited with code 2 (0x2)Native' 已退出,代码为 2 (0x2)
【发布时间】:2014-06-19 05:29:42
【问题描述】:

我正在使用 windows8.1、visual studio10 和 Opencv。 这是我的代码

#include "stdafx.h"

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <opencv/cvaux.h>
#include <stdio.h>

using namespace cv;
using namespace std;

int main(int argc, const char * argv[]){

//mat数据结构使用方法

int Arr[256];
int x;
Mat image, A, B;

image = imread("C:/Users/chandanawin8/Desktop/len.jpg", CV_LOAD_IMAGE_COLOR);

for(int a=0; a<255;a++){       

    Arr[a] = 0;         } 
//int Arr[256] = {0}   

  if(!image.data){

    printf("Error: Couldn't open the file.\n");
    return 2;

}

  cvtColor(image, A, CV_RGB2GRAY);    

//creating the histogram by taking a count to an arry

for(int i=0; i<A.rows; i++){        

    for(int j=0; j<A.cols;j++){            

x = A.at<uchar>(i,j);
Arr[x] = Arr[x]+1;

        if(x<103){           

            A.at<uchar>(i,j) = 0;    }

        else if(x<219){

            A.at<uchar>(i,j) = (x-103)*(220-1)/(219-103) + 1;        
  }

        else if(x<242){

            A.at<uchar>(i,j) = (x-219)*(255-220)/(242-219) +219;

        }

        else{

        }

        //pixels from 241 to 255: keep them. if want we can remove it

    }

}



for(int a=0; a<255;a++){   

std::cout<<"Number of  "<<a<<"  Value: "<<Arr[a]<<std::endl;

   }



//creating the font
//cvInitFont(&font, CV_FONT_HERSHEY_COMPLEX, 3,3, 0.0, 5,8);

//display the image
cvNamedWindow("Main Window", CV_WINDOW_AUTOSIZE);
    imshow("Main Window", image);

    cvNamedWindow("Display Window", CV_WINDOW_AUTOSIZE);
    imshow("Display Window", A);

cv::waitKey(0);
  image.release();
A.release();    

return 0;

}

运行后出现此错误

'BreailTest2.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
The program '[3044] BreailTest2.exe: Native' has exited with code 2 (0x2).

你能帮我解决这个问题吗 几天前它工作了。现在它不工作了。我有点新的opencv和视觉工作室 非常感谢

【问题讨论】:

    标签: c++ visual-studio-2010 opencv image-processing dll


    【解决方案1】:

    问题是您的图片加载不正确。

    如果您查看日志,它会告诉您应用程序以代码 2 退出。

    如果您查看您的代码,只需将其以 2 退出即可

    if(!image.data){
    
        printf("Error: Couldn't open the file.\n");
        return 2;
    
    }
    

    因此,我会检查您输入的文件路径是否正确,以及图像文件是否存在,

    【讨论】:

      【解决方案2】:

      使用Imread函数时出现问题

      image = imread("C:/Users/chandanawin8/Desktop/len.jpg", CV_LOAD_IMAGE_COLOR);
      

      上面的函数使用波纹管函数

      image = cvLoadImage("C:/Users/chandanawin8/Desktop/easy.JPG",CV_LOAD_IMAGE_COLOR);
      

      【讨论】:

      • 亲爱的,不。馊主意。应避免使用旧的 c-api 调用。如果 imread 不工作,你有一个更大的链接器相关的问题潜伏在下面。检查您是否混合了调试/发布库等。
      • 感谢您的回复。当我使用它时 cvloardImage 功能。它正在工作..你解释一下你说 chek debug / release Libs ..我是 opencV 的新手
      • 如果你不知道答案不涉及
      猜你喜欢
      • 1970-01-01
      • 2012-03-25
      • 1970-01-01
      • 2018-07-25
      • 1970-01-01
      • 2012-07-20
      • 2018-08-10
      • 1970-01-01
      • 2023-02-14
      相关资源
      最近更新 更多