- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要在我的代码中使用 getRectSubPix 函数作为裁剪和旋转图像部分的过程的一部分。这通常适用于 3 channel 图像,但一旦我尝试将它与 BGRA 或 RGBA 垫图像一起使用,它就会崩溃,对我说
OpenCV Error: Unsupported format or combination of formats () in cvGetRectSubPix, file /home/biotracking/Downloads/OpenCV-2.4.2/modules/imgproc/src/samplers.cpp, line 550
我的代码基本上是这样的
cv::cvtColor(polymask, polymask, CV_BGR2BGRA);
getRectSubPix(polymask, cv::Size(sqrt(biggestdistancesquared)*2,sqrt(biggestdistancesquared)*2), src_center, polymask);
如果此功能真的不适用于带有 alpha channel 的垫子,那似乎很疯狂。有人知道吗?
最佳答案
前一段时间我注意到了这个问题和@blorggggg的回答,深深地怀疑,因为问题与channels有关,而答案与depth有关.
我的回答:错误上升是因为 getRectSubPix
仅支持 channel 1 或 3 的图像。
相关代码:
if( (cn != 1 && cn != 3) || !CV_ARE_CNS_EQ( src, dst ))
CV_Error( CV_StsUnsupportedFormat, "" );
线程中的语句here by @luhb 是真的,因为它确实只支持深度 8 或 32 的图像是真的,但与这里的问题无关。
相关代码:
if( CV_MAT_DEPTH( src->type ) != CV_8U || CV_MAT_DEPTH( dst->type ) != CV_32F )
CV_Error( CV_StsUnsupportedFormat, "" );
我检查了2.4/2.8/2.9版本的代码片段。
最后,为了解决你的麻烦,你可以先拆分Mat,在每个 channel 上getRectSuxPix
,然后合并四个 channel 。
关于带有 Alpha channel 的 OpenCV getRectSubPix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12048381/
我需要在我的代码中使用 getRectSubPix 函数作为裁剪和旋转图像部分的过程的一部分。这通常适用于 3 channel 图像,但一旦我尝试将它与 BGRA 或 RGBA 垫图像一起使用,它就会
OpenCV 文档 getRectSubPix () 函数: C++: void getRectSubPix(InputArray image, Size patchSize, Point2f cen
我在图像上找到了一个 rotatedRect,我想检索这个 rotatedRect 中所有像素的子矩阵。我在这个主题上找到了这个 C++ 代码:http://answers.opencv.org/qu
在他们的文档中: http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#getrectsubpix 公式是
运行 cv2.getRectSubPix(img, (5,5), (0,0)) 抛出错误: OpenCV Error: Unsupported format or combination of for
我是一名优秀的程序员,十分优秀!