0

我正在使用 OpenCascade 示例项目,我需要提取 3DViewer 场景的 2D 快照并将其转换为 Opencv Mat 格式。我尝试了下面的代码,如果我使用 imshow 显示快照,我将得到一个完整的黑色视图。默认情况下,PixMap 是 3 通道 RGB 图像。

Image_PixMap img;
getViewer()->ActiveView()->ToPixMap(img, 1024, 1024);
cv::Mat* mat_img = new cv::Mat(1024, 1024, CV_8UC3);
img.InitWrapper(Image_Format_RGB, mat_img->ptr(), 1024, 1024);
Standard_EXPORT virtual bool InitWrapper (Image_Format thePixelFormat,
                                            Standard_Byte*       theDataPtr,
                                            const Standard_Size  theSizeX,
                                            const Standard_Size  theSizeY,
                                            const Standard_Size  theSizeRowBytes = 0);
 Standard_Boolean ToPixMap (Image_PixMap& theImage,
                             const Standard_Integer theWidth,
                             const Standard_Integer theHeight,
                             const Graphic3d_BufferType& theBufferType     = Graphic3d_BT_RGB,
                             const Standard_Boolean      theToAdjustAspect = Standard_True,
                             const V3d_StereoDumpOptions theStereoOptions  = V3d_SDO_MONO)
4

0 回答 0