为了获取 OpenCV 中的像素,我使用以下代码:
for( int y=0; y<image->height; y++ ) {
uchar* ptr = (uchar*) (image->imageData + y * image->widthStep);
for( int x=0; x<image->width; x++ ) {
byteArray[y*image->widthStep+3*x] = ptr[3*x];
byteArray[y*image->widthStep+3*x+1] = ptr[3*x+1];
byteArray[y*image->widthStep+3*x+2] = ptr[3*x+2];
}
}
但我不能在 EmguCV 中使用这样的代码:
for( int y=0; y<rgb32Image->MIplImage.height; y++ ) {
unsigned char* ptr = (unsigned char*) (rgb32Image->MIplImage.imageData + y*rgb32Image->MIplImage.widthStep);
//error C2678: binary '+' : no operator found which takes a left-hand operand of type 'System::IntPtr' (or there is no acceptable conversion)
for( int x=0; x<rgb32Image->MIplImage.widthStep; x++ ) {
b[y*rgb32Image->MIplImage.widthStep+3*x] = ptr[3*x];
b[y*rgb32Image->MIplImage.widthStep+3*x+1] = ptr[3*x+1];
b[y*rgb32Image->MIplImage.widthStep+3*x+2] = ptr[3*x+2];
}
}
我应该用什么代替 MIplImage.imageData 来获取 Emgu CV 中图像的像素?
谢谢!