Ask Your Question

How can Caffe be interfaced using OpenCV

asked 2015-10-05 12:40:19 -0500

215 gravatar image

Hi guys.. I kinda new to the deep learning stuff so I hope you can help me a bit.

I installed Caffe, and trained a classifier (mnist example) which is capable of detecting digits.

The classifier is of filetype .caffemodel, and was wondering if it possible to it with OpenCV to test its performance example in realtime.

I tried googling everywhere, and don't seem to be able to find one example which loads and simple image, apply the classifier on to it, and thereby determine whether or not the image contains the object which the classifier contains.

Is that a too hard task, or should one be able to apply the classifier which Caffe has modeled?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-10-05 21:44:26 -0500

berak gravatar image

updated 2015-10-07 04:40:54 -0500

There is a new dnn module in opencv3/contrib, that allows you to load pretrained caffe or torch models, and do a prediction in opencv

edit flag offensive delete link more



You got it correct, so take the credit for it ;)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-07 04:41:08 -0500 )edit

yea, right, thanks. i was actually hoping, that more folks had tried it, and would have first hand experience !

berak gravatar imageberak ( 2015-10-07 07:04:33 -0500 )edit

Please update the link

eshirima gravatar imageeshirima ( 2017-06-27 15:48:13 -0500 )edit

@eshirima its not that difficult: . Since the comment in 2015, the module was moved to the main OpenCV branch!

StevenPuttemans gravatar imageStevenPuttemans ( 2017-07-12 09:13:47 -0500 )edit

@StevenPuttemans I know it seemed like a rather stupid comment but I had no knowledge of the move. I tried digging for it in contrib. I appreciate the response

eshirima gravatar imageeshirima ( 2017-07-12 10:00:59 -0500 )edit

answered 2015-10-07 08:01:51 -0500

dtmoodie gravatar image

updated 2015-10-07 08:03:13 -0500

If you want to use the version of caffe that you built, you can use something like this to interface it with your code: Mainly look at the wrapInput() for wrapping a cv::cuda::GpuMat into a caffe::blob, and doProcess for actually processing an image with caffe.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-10-05 12:40:19 -0500

Seen: 1,785 times

Last updated: Oct 07 '15