Webcam realtime classification?

442 views
Skip to first unread message

Deepak Soekhoe

unread,
Feb 9, 2016, 9:31:05 PM2/9/16
to Caffe Users
Are there any good tutorials for connecting Caffe with a webcam to do realtime classification?

Felix Abecassis

unread,
Feb 9, 2016, 11:37:16 PM2/9/16
to Caffe Users
It should be easy, use the OpenCV API VideoCapture:
http://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture

You can use this API in Python and get numpy objects that you can pass to Caffe:
https://github.com/BVLC/caffe/blob/master/python/classify.py

Similarly, you can use cv::VideoCapture in C++ and create a C++ classifier like this one:
https://github.com/BVLC/caffe/tree/master/examples/cpp_classification

Deepak Soekhoe

unread,
Feb 10, 2016, 7:10:50 AM2/10/16
to Caffe Users
Thanks for the links Felix! I will take a look :)

Adrita Barari

unread,
Oct 20, 2016, 1:49:24 AM10/20/16
to Caffe Users
Hi Felix,

I am just a beginner in Caffe and I ran the classification example in python. I created my own dataset and used both Alexnet and Caffenet for classification. I am running this on a CPU (4GB RAM) and I am aware that my performance is suffering because of that. (Each frame takes about 2 seconds to process in Alexnet and some 0.94 seconds in Caffenet). Can you please suggest how I can improve the speed on a CPU? Will running the classification on C++ make it better?

Thanks in advance.

Felix Abecassis

unread,
Oct 20, 2016, 2:13:03 AM10/20/16
to Caffe Users
Hello Adrita,

Using C++ might indeed improve classification performance, but I wouldn't recommend doing it yet if you are a beginner with Caffe.
As a starting point, try compiling caffe with OpenBLAS as the BLAS library. Ideally, you should compile OpenBLAS from sources, to get the latest optimizations.
Reply all
Reply to author
Forward
0 new messages