bitwise_or Opencv Exception
bitwise_or Opencv Exception
我正在尝试在我的图像上应用骨架化bitwise_or但它在 opencv 的功能上引发异常
cv::threshold(input, input, 127, 255, cv::THRESH_BINARY);
cv::Mat skel(input.size(), CV_8UC1, cv::Scalar(0));
cv::Mat temp(input.size(), CV_8UC1);
cv::Mat element = cv::getStructuringElement(cv::MORPH_CROSS, cv::Size(3, 3));
bool done;
do
{
cv::morphologyEx(input, temp, cv::MORPH_OPEN, element);
cv::bitwise_not(temp, temp);
cv::bitwise_and(input, temp, temp);
cv::bitwise_or(skel, temp, skel);
cv::erode(input, input, element);
double max;
cv::minMaxLoc(input, 0, &max);
done = (max == 0);
} while (!done);
抛出bitwise_or例外情况是
C:buildsmaster_PackSlave-win32-vc12-staticopencvmodulescoresrcarithm.cpp:1573: error: (-209) The operation is neither 'array op array' (where arrays have the same size and type), nor 'array op scalar', nor 'scalar op array' in function cv::binary_op
代码来源:http://felix.abecassis.me/2011/09/opencv-morphological-skeleton/
如果input
图像不是CV_8UC1
,我可以重现此错误。请确保input
是灰度图像。
你需要提供一些标量。例如:
bitwise_or(mat1, Scalar(0,0,0,255), mat2);
在您的代码中,temp
Mat 中没有值(因为您只使用大小创建了它)。尝试类似操作:
cv::Mat temp(input.size(), CV_8UC1, cv::Scalar(0));
这将创建一个用零填充的矩阵,您可以将其用作 bitwise_or
函数的标量。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将OpenCV C++重写为EmguCV C#-如何使用指针
- OpenCV C++.快速计算混淆矩阵
- 在C++代码中包含opencv时,使用ctypes创建.so文件
- 哪些库可以通过Opencv调整曝光率
- opencv cv::addText exception if no window
- opencv imencode() buffer exception
- Opencv Simpleblobdetector示例草图抛出cv::exception(-231)
- 使用 OpenCV /C++ 应用精明边缘检测器后出现"Unhandled exception"错误
- OpenCV: findContours exception
- Opencv solve throws cv::Exception
- bitwise_or Opencv Exception
- openCV 中的 SVM 抛出"cv::Exception at memory location"
- OpenCV cv::findcontours StackOverflow Exception
- cvtColor 断言失败(带有 C++ 的 OpenCV )抛出一个实例 cv::exception
- Opencv PCA Microsoft c++ exception: cv::内存位置异常