Real-time OpenCV performance in Java and C ++

I understand that there are a number of similar questions, but I believe that my situation is unique enough to justify my own post.

I am working on a “visual guide” - I created a program that tracks human hand gestures and extrapolates the tempo (in beats per minute) from these gestures. Now I would like to display the measured tempo in a MIDI file that plays while a person is conducting. In principle, I would like the program to allow someone to conduct a synthesized play, where the tempo of the file being played depends on the gestures of the explorer in real time. I wrote this in C ++ using the OpenCV libraries.

Here, where things get interesting / hairy. Changing the tempo of a MIDI file directly is a daunting task, and given the limited time I left this summer, I decided to look elsewhere. I managed to find the Sequencer interface in the Java API, which has an excellent method called setTempoinBPM . He does exactly what I need; I just failed to get it working in my C ++ code.

I tried to create my own JVM to call Java methods in C ++ code, but to no avail. I also tried calling Java programs by passing the appropriate command line arguments to system() , but I cannot change the tempo of the MIDI file after starting playback using this approach.

I am considering converting my C ++ code to Java code to directly call setTempoinBPM() , but I have heard conflicting messages about whether this will affect OpenCV performance.

I would like your opinion: the performance of OpenCV in Java is comparable enough to its performance in C ++, which would turn my project into Java? (If you happen to know how easy it is to change the tempo of a MIDI track, feel free to share it.)

+4
source share
2 answers

Instead of mapping to a MIDI file, perhaps you can follow the parsing / compiling method.

Think of MIDI as a representation of data (serialized). Parse the data into an intermediate representation (IR) that makes sense for your specific problem (i.e., Pace Control). Just think: "How do I better structure the data in memory so that it's easy to control the pace?"

Then, using a package like this , you can parse the midi file and extract the important parts. This package may have an IR that is suitable for your problem. Of course, it looks like he has a serialization method that you might need to enter the file back into the player. In addition, you can find a player with whom you can directly transfer your IR. If you choose an IR that is already used for a famous player (and it is still suitable for tempo manipulation), you do not have to consider serializing your IR after you change it.

Hope this helps ...

0
source

I am not very good at C ++, but I used midi a bit through openFrameworks and ofxMidi .

Behind the scenes, he uses rtMidi .

Performing a quick search, it seems that you can control the pace directly from C ++ (see the bottom of void RtMidiIn :: initialize method). Not sure if there is a good clean API because I haven't used rtMidi so much, but maybe worth checking out.

0
source

Source: https://habr.com/ru/post/1494109/


All Articles