opencv打开bmp图像时,debug无法查看到imageData的值。
各位,请教大家一个问题,可能大家觉得这个问题很简单,但这个问题却实在是困扰我很久了。我有一张bmp图片,图片大部分是黑色的。用opencv打开,然后显示。图片显示完全正常,但是在debug里面无法看到这张图片的imageData数据,只能这张图片的width、height、nChannels等的属性,但就是看不到它的imageData,不知道这是怎么回事,请大家指点。但是当我载入的图像时彩色的或者是图像信息比较丰富时,debug时查看imageData的时候是能查看到数据的,真的不知道是什么原因了,求指导???
程序代码:
#include "stdafx.h"
#include "opencv2/opencv.hpp"
#include <time.h>
#include <math.h>
#include <ctype.h>
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* frame;
frame = cvLoadImage("afterProcess.bmp",1);
cvNamedWindow("show_image",WINDOW_AUTOSIZE);
while (true)
{
cvShowImage("show_image",frame);
if(waitKey(33)==27)
{
break;
}
}
destroyWindow("show_image");
cvReleaseImage(&frame);
return 0;
}
求各位大侠指点。
[解决办法]
#include "stdafx.h"
#include "opencv2/opencv.hpp"
#include <time.h>
#include <math.h>
#include <ctype.h>
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* frame;
frame = cvLoadImage("afterProcess.bmp",1);
cvNamedWindow("show_image",WINDOW_AUTOSIZE);
for(int i=0;i<Frame->height;i++)
{
for(int j=0;j<Frame->width;j++)
{
BYTE data1=(BYTE)frame->imageData[i*frame->widthStep+j];
}
}
while (true)
{
cvShowImage("show_image",frame);
if(waitKey(33)==27)
{
break;
}
}
destroyWindow("show_image");
cvReleaseImage(&frame);
return 0;
}
data1就是图像的数据了,你可以单步就看到了
[解决办法]
Debug查看的方法不对吧?如果能够正常显示的话,imageData里面肯定有值的