2016-02-21 43 views
0

錯誤我是一個關於OpenCV的初學者。我搜索並試圖執行一些基本的OpenCV代碼。當我試圖運行其中的一個,我得到了「R6010 -abort()被調用」的錯誤。我也試着調試代碼,但這個時間線28它給了我「微軟C++異常:內存位置0x000000A7F732F350 CV ::例外」錯誤。OpenCV的R6010()中止被稱爲在Visual Studio 2012

// work5animage.cpp : Defines the entry point for the console application. 

#include "stdafx.h" 

#include <iostream> 
#include <string> 
#include <sstream> 
using namespace std; 

#include "opencv2\core.hpp" 
#include "opencv2\imgproc.hpp" 
#include "opencv2\highgui.hpp" 

using namespace cv; 
int main(int argc, const char** argv) 
{ 
// Read images 
Mat color= imread("resized_love.jpg"); 
Mat gray= imread("resized_love.jpg", 0); 
// Write images 
imwrite("lenaGray.jpg", gray); 


// Get same pixel with opencv function 
int myRow=color.cols-1; 
int myCol=color.rows-1; 
Vec3b pixel= color.at<Vec3b>(myRow, myCol); //This is where I get the err. 
cout << "Pixel value (B,G,R): (" << (int)pixel[0] << "," << 
(int)pixel[1] << "," << (int)pixel[2] << ")" << endl; 
// show images 
imshow("Lena BGR", color); 
imshow("Lena Gray", gray); 
// wait for any key press 
waitKey(1000); 
return 0; 
} 

我看到一些相關的問題,但我找不到一個方便的答案。謝謝你的幫助。

回答

0

我想就像你要訪問它JPG不會在普通2D格式存儲。將其轉換爲BMP,請仔細閱讀,然後再試一次。