是否有任何版本的CvBlobs库使用cv :: Mat? [英] Is there any version of CvBlobs library which works with cv::Mat?

查看:284
本文介绍了是否有任何版本的CvBlobs库使用cv :: Mat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现了 CvBlobsLib ,它可以是一个祝福,但它可悲的使用IplImage。

有没有机会有一个新的cv :: Mat风格的版本,我不会碰巧找到它?

I have just discovered CvBlobsLib that can be a bless but it sadly uses IplImage.
Is there any chance that there is a new cv::Mat-style edition I just don't happen to find it?

编辑:

原来,我碰巧发现了2个不同的库,CvBlobsLib和CvBlobs,yeehaa。 :)

我看到CvBlobsLib比cvBlobs更少使用,那不是在opencv willowgarage,而是在google代码。我欢迎两个图书馆的答案,虽然,因为两个工作与IplImage。 :)

It turned out that I happened to discover 2 distinct libraries, CvBlobsLib and CvBlobs, yeehaa. :)
I saw CvBlobsLib is less used than cvBlobs, that is NOT on opencv willowgarage but on google code. I welcome answers for both libraries, though, as both work with IplImage. :)

推荐答案

编辑:我说的是 cvBlobs 在这个答案,对不起,我搞砸了 cvBlobsLib ...

I'm talking about cvBlobs in this answer, sorry that I messed it up with cvBlobsLib ...

我一直在找这个,

但实际上你总是可以这样做: IplImage iplImg = mat; ,只需使用& iplimg ,无论您需要 IplImage *

But actually you can always do this: IplImage iplImg = mat; and just use &iplimg wherever you need an IplImage*.

我在一些项目中使用了 cvBlobs 这种方式:

I used cvBlobs this way successful in a few projects:

#include <cvblob.h>
using namespace cvb;

// load image
cv::Mat mat = cv::imread("image.jpg");

// convert cv::Mat to IplImage
IplImage img = mat;

// convert to grayscale
IplImage *gray = cvCreateImage( cvGetSize(&img), IPL_DEPTH_8U, 1 );
cvCvtColor( &img, gray, CV_BGR2GRAY );

// get binary image
cvThreshold( gray, gray, 150, 255, CV_THRESH_BINARY );

// get blobs
IplImage *labelImg = cvCreateImage( cvGetSize(gray), IPL_DEPTH_LABEL, 1 );
CvBlobs blobs;
unsigned int result = cvLabel( gray, labelImg, blobs );

// render blobs in original image
cvRenderBlobs( labelImg, blobs, &img, &img );

// *always* remember freeing unused IplImages
cvReleaseImage( labelImg );
cvReleaseImage( gray ); 

// convert back to cv::Mat
cv::Mat output( &img );

这篇关于是否有任何版本的CvBlobs库使用cv :: Mat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆