OpenCV提取IplImage图像数据问题
voidcannyEdge(IplImage*image){IplImage*gray=0;IplImage*edge=0;IplImage*cedge=0;//crea...
void cannyEdge(IplImage* image)
{
IplImage *gray = 0;
IplImage *edge = 0;
IplImage *cedge = 0;
//create the output image
cedge = cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,3);
//convert to grayscale
gray = cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,1);
edge = cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,1);
//cvSmooth(image,image);
cvCvtColor(image,gray,CV_BGR2GRAY);
//deal with the image
// cvSmooth(gray,gray,CV_BLUR,3,3,0,0);
cvNot(gray,edge);
//run the edge detector on grayscale
cvCanny(gray,edge,(float)100,(float)300,3);
//copy edge points
cvCopy(image,cedge,edge);
int w=0,h=0,i,j;
unsigned char *data;
//data=reinterpret_cast<unsigned char *>(img->imageData);
data= (unsigned char*)(edge->imageData);
w=edge->width;
h=edge->height;
for(j=0;j<h;j++)
{
for(i=0;i<w;i++)
{
cout<<data[w*j+i];
}
cout<<endl;
}
//show the edge
cvNamedWindow( "edge", 1 );//创建窗口
cvShowImage("edge",edge);//显示图像
}
这段代码是Canny边缘检测,然后我想提取edge中的数据进行处理,但却提不出数据,刚学OpenCV,求指教。并且这种方法
unsigned char *data;
//data=reinterpret_cast<unsigned char *>(img->imageData);
data= (unsigned char*)(edge->imageData);
怎么提出的都是乱码字符呢? 展开
{
IplImage *gray = 0;
IplImage *edge = 0;
IplImage *cedge = 0;
//create the output image
cedge = cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,3);
//convert to grayscale
gray = cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,1);
edge = cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,1);
//cvSmooth(image,image);
cvCvtColor(image,gray,CV_BGR2GRAY);
//deal with the image
// cvSmooth(gray,gray,CV_BLUR,3,3,0,0);
cvNot(gray,edge);
//run the edge detector on grayscale
cvCanny(gray,edge,(float)100,(float)300,3);
//copy edge points
cvCopy(image,cedge,edge);
int w=0,h=0,i,j;
unsigned char *data;
//data=reinterpret_cast<unsigned char *>(img->imageData);
data= (unsigned char*)(edge->imageData);
w=edge->width;
h=edge->height;
for(j=0;j<h;j++)
{
for(i=0;i<w;i++)
{
cout<<data[w*j+i];
}
cout<<endl;
}
//show the edge
cvNamedWindow( "edge", 1 );//创建窗口
cvShowImage("edge",edge);//显示图像
}
这段代码是Canny边缘检测,然后我想提取edge中的数据进行处理,但却提不出数据,刚学OpenCV,求指教。并且这种方法
unsigned char *data;
//data=reinterpret_cast<unsigned char *>(img->imageData);
data= (unsigned char*)(edge->imageData);
怎么提出的都是乱码字符呢? 展开
1个回答
东莞大凡
2024-08-07 广告
2024-08-07 广告
OpenCV标定板是东莞市大凡光学科技有限公司在相机标定中常用的工具。它通常由黑白格点按一定规则排列在平面上组成,如棋盘格或圆形格等。在相机标定时,将标定板置于不同位置和姿态下拍摄图像,利用OpenCV库中的函数检测标定板上的角点或圆心,进...
点击进入详情页
本回答由东莞大凡提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询