我遇到了一个很大的问题。在通过互联网搜索之后,我没有找到一个好的解决方案。我通过opencv(2.3)从文件中读取图像并操作它们。之后,我想在我的应用程序中使用wxwidgets(2.9.3)编写结果。主要的问题是,我的图像是灰度的,所以我只有一个数据指针,但wxwidgets只是使用RGB。只是一个小例子:在opencv和wxwidgets之间转换图像
cv::imread(filename,CV_LOAD_IMAGE_GRAYSCALE).convertTo(pictureMatrix,CV_32F,(float)(1/2.0f),0);
// here are some more floating point calculations
cv::Mat output;
pictureMatrix.convertTo(output,CV_8U);
wxImage test(output.rows, output.cols, output.data, true);
wxInitAllImageHandlers();
// saving the picture is just for testing, if it works
test.SaveFile("test.png", wxBITMAP_TYPE_PNG);
该解决方案也适用,但按像素访问不是必需的。谢谢 – Sonic