图像边界框的周长

Perimeter of bounding box of an image

本文关键字:周长 边界 图像      更新时间:2023-10-16

我需要使用C++在OpenCV中找到图像边界框的周长。使用double perimeter = arcLength(rois[wp],true);时,将生成以下错误:

Assertion failed (count >= 0 && (depth == CV_32F || depth == CV_32S)) in arcLength,
file /home/vidushi/Desktop/OpenCV/modules/imgproc/src/shapedescr.cpp,
line 285 terminate called after throwing an instance of 'cv::Exception'
what():  /home/vidushi/Desktop/OpenCV/modules/imgproc/src/shapedescr.cpp:285: 
error: (-215) count >= 0 && (depth == CV_32F || depth == CV_32S) in function arcLength

有人可以解释一下可能是什么问题吗?

基本上,arcLength函数不接受rois[wp]的格式。它必须是 2D 的,并且具有CV_32S或CV_32F深度。类似于cv::Mat valid_roi(n, 2, CV_32F);(适应您的问题(。