开发者_运维知识库Can I use OpenCV
with Ruby on Rails
? If so, how can I do that? Or, what resources do you recommend for that?
Thanks.
There is also an open CV gem, fwiw -- https://github.com/ruby-opencv/ruby-opencv.
Sure you can! It just depends on what do you need as there is no "one" silver bullet.
If you want to create an online home surveillance, for example, then you would probably have least effort by writing:
- C++ image-processing command-line application on top of OpenCV that would write the surveillance events and/or images to SQLite database.
- Read the database directly from Rails.
For anything more complex, you'd need a more complex architecture.
Whatever you do, pick the best tools for the purpose:
- Let OpenCV do what it is best at (image processing)
- Let Rails to it's magic (simple, less demanding online access to some resources)
In order to link OpenCV and Ruby together, you could create a dedicated Ruby-to-C++ bridge because none of the existing ones can match diverse needs and most frameworks will do for a few specialized (i.e. designed by you) function-calls through your bridge.
This link would be a good start to pick a framework for a bridge - just go for one and see what comes out.
You could write a program using OpenCV in C++, and then just process your data with it, by using CGI (Common Gateway Interface http://en.wikipedia.org/wiki/Common_Gateway_Interface). I don't think you can bind native code to Ruby like you can do in Java (JNI)
精彩评论