0

These are some "windows" shown in the watershed demo of OpenCV package.

Interaction between user and the app includes some simple discrete input characters and I barely see any sort-of command line input.

I'd like to make it just a bit more convenient interaction. something likes:

funcA arg1 arg2Enter funcB arg1 ... Enter

after "enter", the command is run

is there anything like that in OpenCV??

watershed demo of OpenCV

TSL_
  • 2,049
  • 3
  • 34
  • 55
  • Qt can be used to make sophisticated GUI. But I'm not having any work with GUI design – TSL_ Sep 09 '12 at 14:37

2 Answers2

0

The code for the demo is available with your OpenCV installation.
You can adjust it as you like.

Adi Shavit
  • 16,743
  • 5
  • 67
  • 137
  • I mean I don't know how to code such command input: funcA arg1 arg2Enter OR funcB arg1 ... Enter. Any hint? – TSL_ Sep 09 '12 at 14:40
  • The code is written in C/C++. If you cannot write C/C++ then I am afraid you're out of luck. – Adi Shavit Sep 09 '12 at 18:05
  • the coding is OK. but here I don't know how to approach. This is similar to reading a whole string line funcA arg1 arg2Enter. Enter is to notify command input by user; then, string line is splitted to funcA, arg1 and arg2 to process and call the correct function. – TSL_ Sep 10 '12 at 01:30
0

Are you saying that you want to call a function of your program while the program is running to process the images? For example while the program is running you call watershed(whatever, arguments) ?

I don't think that you can do that without some effort. I haven't tried anything like it, but what comes to my mind is using a separate thread to get input and then map that input to a function.

Edit: See also this answer if indeed this is what you are looking for.

Community
  • 1
  • 1
Sassa
  • 3,294
  • 2
  • 28
  • 42
  • if you have tried watershed demo or some other demos of OpenCV, you will understand what I mean. simply speaking, while the images are being shown, I'd like to process commands like "funcA arg1 arg2" from the user keyboard input – TSL_ Sep 10 '12 at 02:55
  • I have tried that demo, isn't what you are saying the same with what I wrote? OpenCV doesn't provide you with a way to do that, you can use WaitKey() for a specific key and you have a mouse callback but that's it. If you want that kind of functionality you have to write it yourself. – Sassa Sep 10 '12 at 03:19
  • So, I have to write another thread to perform that, for example, using TBB?? Is there a simpler way-around?? I've read for a while about TBB and it's likely to be a distant application to me – TSL_ Sep 10 '12 at 03:31
  • if the TBB coding here is simple, please help me more clearly... some coding for example – TSL_ Sep 10 '12 at 03:33
  • I am sorry, but I really cannot help you more with that, I've never used TBB. Since you want that kind of interaction, why don't you reconsider using Qt to create a very simple GUI? You don't even have to incorporate the OpenCV window if you don't want to, you could create just a simple GUI with a button for the function and a couple of textedits for the arguments and then show the images with imshow() as you would with OpenCV. – Sassa Sep 10 '12 at 05:22
  • I guess I'll have to consider this direction since I already can work on simple Qt and the Qt-OpenCV integration. Thanks for the suggestion! – TSL_ Sep 10 '12 at 06:15