OpenCv and Ruby on Rails - c++

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)

Related

Accessing the tools like gimp(installed at server) from client

I want to create an web application through which i have to access tools like Gimp for my image processing. Is it possible to manage my need with client-server (Gimp at server) approach?
I am not restricting with the Gimp,however i prefer any opensource with basic functionality(zoom out/in,selection tool, cropping tool, transparent tool etc).
Sorry if the question is so wage as i am not much familiar with these kind of architectures.
And i hope this(stackoverflow) is the platform to get help from people.
There are several ways of doing image processing in the server of a web application.
One approach would be to invoke a tool through command-line (I think that is what you are trying to do with gimp).
Second approach would be to use a image manipulation library in the language you are using for developing the application. (Sometimes I did this with Java)
Use a combination of the above depending on the kind of manipulation you wish.
But with today browser capabilities, some processing can be done using HTML5 (canvas) + Javascript in the client itself. For instance you can use something like this for cropping:
http://www.webresourcesdepot.com/jquery-image-crop-plugin-jcrop/
Or something like this for image maniplation in Javascript:
http://pixastic.com/
So, there are plenty of choices. There is no a better approach, it all depends on the kind of processings, the size of the images, the hardware you have, etc.
Wish it helps...

Creating gui binding for c++ and YUI

I am planning to use yui or jquery ui as front end for native c++ applications. I found no bindings present for this purpose. Will it be feasible/possible to do this ? If it is so, then how shall i proceed? please suggest advice.thanks
#rwik - I can see your point and desire to do what you intend and I would presume it to be a wise move to be making at this point in time considering the vast facilities browsers bring to the table as well as other aspects... I know we are in September now and I have come across this pretty late, but this is also for others who have a similar problem...
As far as I know, descending from JavaScript in to C++ is pretty murky, mostly due to the heterogenous nature of Javascript engines [Rhino, Tracemonkey, Spidermonkey, V8, Caracan,Charka, etc] employed by different browsers. But there are indeed ways to do this - depending on how dirty you want to get your hands and, indeed, on your abilities...
If you were to go with Google as a browser, you should take a look at projects such as cproxyv8 - http://code.google.com/p/cproxyv8/ or v8-juice - http://code.google.com/p/v8-juice/ which both offer interesting facilities...
My preference however is with Mozilla - simply because of XML User-Interface Language (XUL) which, if you do not know, allows you to speedily create your own user interfaces by giving direct access to its layout engine. I.e., you can even do away with the browser look and have your own independent layout while still having all browser facilities at your disposal.
With respect to C++/Javascript interaction - projects should exist for all alternatives - it pays to check.
I wish you good luck if you haven't already solved this problem.
I'd recommend QT instead.
However since native C++ has nothing to do with GUI I'm going to assume you are making a library in C++. However Yui is basically just JavaScript as is jQuery. So if you're asking can a web page or script be a C++ application the answer is not really.
What you could do is create a web service which uses your C++ library and exposes an interface for your web based application to call it indirectly.
One way to accomplish this is to embed WebKit into your application and provide your custom C++ functionality via a plugin. Both the WebKit framework on OSX and the Chromium Embedded Framework on Windows allow this style of application development. This allows you to write a UI using local Javascript/HTML files without the need for a webserver.
There are no direct bindings in JQuery and YUI because these libraries run in a web browser. Thus unless you’re planning to write your own browser plugins, the integration with the C++ will happen at the webserver that serves the data to the browser.
You could feed the data from your C++ code directly into JQuery/YUI by building web services directly in C++. But you might want to build a web application that will be serving your JQuery/YUI pages and that act as user interface controller (like in the MVC pattern). Web application languages like Java, PHP, etc. all have ways to call native code. Java has JNDI and in PHP you build extensions that link to C++ code.

How does one port c++ functions to the internet?

I have a few years experience programming c++ and a little less then that using Qt. I built a data mining software using Qt and I want to make it available online. Unfortunately, I know close to nothing about web programming. Firstly, how easy or hard is this to do and what is the best way to go about it?
Supposing I am looking to hire someone to make me a secure, long-term, extensible, website for an online software service, what skill set should I be looking for?
Edit:
I want to make my question a little more specific:
How can I take a bunch of working c++ functions and port the code so I can run it server side on a website?
Once this is done, would it be easy to make changes to the c++ code and have the algorithm automatically update on the site?
What technologies would be involved? Are there any cloud computing platforms that would be good for something like this?
#Niklaos-what does it mean to build a library and how does one do that?
You might want to have a look at Wt[1]. Its a C++ web framework which is programmed more or less like a desktop GUI application. One of the use cases quoted is to bring legacy apps into the web.
[1] http://www.webtoolkit.eu
Port the functions to Java, easily done from C++, you can even find some tools to help - don't trust them implicitly but they could provide a boost.
See longer answer below.
Wrap them in a web application, and deploy them on Google App-Engine.
Java version of a library would be a jar file.
If you really want to be able to update the algorithm implementation dynamically, then you could implement them in Groovy, and upload changes through a form on your webapp, either as files or as a big text block, need to consider version control.
The effort/skillset involved to perform the task depends on how your wrote your code. If it is in a self-contained library, and has a clean (re-entrant, thread safe) API, you could probably hire a web developer (html/php/asp etc) to write the UI interface to the library for a relatively small cost. The skills required would be dependant on the technologies you wanted to use. For Windows development I would suggest C#/ASP. The applicant would require knowledge of interfacing with native libraries from a managed language. This is assuming that you dont mind the costs of Windows deployment for your application.
On the otherhand, if the library is complex or needs to be re-written to support the extensibility you are looking for, asking here will not get you much.
BTW: here is a great article on Marshalling if you chose to implement using C#/ASP
http://msdn.microsoft.com/en-us/magazine/cc164193.aspx
First, DO NOT USE PHP :D
I used it for some projects (the last one with symphony framework) and i almost shoot my self !
If you are very familiar with C++, ASP .NET could be a good solution because if you like C++ you are going to love C#.
Any ways, I personally use Ruby on Rails for 6 months now and I LOVE IT. I won't write you a book here but the framework is pure gold !
The only problem is that Ruby is a very special language. You will probably be a bit lost a the beginning. But as every one you will learn to love it.
But that was only for the server side. Indeed, there 3 technologies you won't be able to avoid if you want to start to develop web applications.
HTML, CSS and JavaScript are presents every where. This is why i'm thinking you should start by HTML and CSS then JavaScript (with jQuery).
When you've got some basics with these 3 technologies you should be able to choose the server side language.
But you've got to tell you one thing, it's not going to be easy !
PS : Ruby on Rails uses HAML and SASS. These 2 languages replaces HTML and CSS you should have a look at them quickly because they are awesome.

How does Gedit expose its api to python for plugins?

I'm starting a medium (academic) project in C++ for which I need users to be able to write small scripts, which interact directly with the main program. My first thought as an aproach to this was to make something like Gedit does with it's plugins (in fact I thought about it because it is something very similar to what I need to do.)
I do have some experience writting plugins for geddit, but zero experience in writting a plugin framework.
Would it be really difficult to me to write one similar to gedit's? (i mean, the way it exposes its API to python, and then loads the python plugin and calls its methods). Can anyone point me in the right directions or teach me a little if you have experience with it?
Fortunately, gedit's plugin framework can be used. You could use Ethos, which is the same plugin framework gedit uses, only without gedit.

Maya API to C++

I was reading about the Maya API to C++ and didn't quite understand the idea.
Upon implementing the API, Can I create an environment, or a GUI in 3D world in Visual Studio?
This question is related to my previous one about the Maya API.
Question
If someone could give me a good place to begin, it would be great.
Thanks,
Oded.
You can't create 3D environment outside the Maya,
as well as you can do anything inside Maya with the API.
I recommend that you start with Maya python API instead of c++ it's way easier, and takes less development time.
you may read the "Complete Maya Programming" book, its example written in c++, but if you know some python you can write them in python.
Maya API allows you to extend Maya, and you can choose to use either c++ or python (the python just wraps same API, more or less). Now the extension framework is meant for you to implement your own nodes, importers/exporters and motion capture devices, mostly. The GUI layer is reserved to scripting components and QT neither which are exactly Maya APIS domain, tough it gives you hooks to do with with the script environment or QT.
As for the exact question can you create a GUI yes you can get a handle to the QT framework, but as i previously said its not the realm of the API per see. And as for the environment yes you could do that its just not the sort of thing you'd do as your first project. You do almost anything you like, inside or even a connection outside of Maya however from a practical standpoint you'd still have to quite intimately know Maya before starting to do so. The API doesn't exactly allow you to do anything you like it has certain no bounds limitations and its not a good idea to fight Mayas run time environment.
If on the other hand you want to control things within Maya externally then make a node or a motion capture server, that's what they are meant for.
Personally i find the complete Maya programming book a bit misleading on all levels but yes you could use it as basis. Just not terribly fruitful for any of the tasks you ask for.