Ask Your Question
2

imshow() and waitKey()

asked 2014-02-05 13:19:06 -0600

SpiderGears gravatar image

I am truing to show the camfeed into a window using imshow() but it needs waitKey() after each frame. Referred to a few aritcles on web that say highgui requires waitkey() to be called in order to get time to update the window.

Is there a workaround with cpp interface to accomplish this without use of waitKey() ?

edit retag flag offensive close merge delete

Comments

have a look at qt ? do you own gui.

berak gravatar imageberak ( 2014-02-05 13:40:14 -0600 )edit

static boost::once_flag cv_thread_flag = BOOST_ONCE_INIT; boost::call_once(cv_thread_flag, &cv::startWindowThread);

found this is page here: http://web.ics.purdue.edu/~yuanl/2011/08/ros-cvnamedwindow-doesnt-show-up/

don't Understand it.

@berak: I am not using qt for my application. Since everything is on main thread... i think i own the gui.

SpiderGears gravatar imageSpiderGears ( 2014-02-05 14:15:50 -0600 )edit
1

how's that related to your question ?

all i'm saying is - you don't have to use the highgui api, warts and all.

berak gravatar imageberak ( 2014-02-05 14:24:56 -0600 )edit

okay... you want me do my own gui. Actually final application won't be gui based. So i guess i shouldnt be putting much time into it right now. Just wanted to explore options for debugging purpose.

thanks for the help though.

SpiderGears gravatar imageSpiderGears ( 2014-02-05 14:37:27 -0600 )edit

hey, yea. another approach to it.

any way, don't worry too long about highgui's deficiances...

berak gravatar imageberak ( 2014-02-05 14:40:48 -0600 )edit

I used wait(1); sleep(3); image stayed around for 3 sec.

keghn gravatar imagekeghn ( 2014-02-06 15:14:32 -0600 )edit

ahhh, keghn, nooo ...

berak gravatar imageberak ( 2014-02-06 15:34:44 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-02-05 13:36:27 -0600

unxnut gravatar image

You can try waitKey(0). That should work well.

edit flag offensive delete link more

Comments

waitKey(0) means wait for keypress infinitely.

Not what I am looking for.

SpiderGears gravatar imageSpiderGears ( 2014-02-05 14:16:51 -0600 )edit

Oops, try waitKey(1).

unxnut gravatar imageunxnut ( 2014-02-05 14:30:10 -0600 )edit

yeah i am already working with waitKey(1)

I wanted get rid of it. I think it will a little cumbersome to do so... may i should ignore it.

SpiderGears gravatar imageSpiderGears ( 2014-02-05 14:38:50 -0600 )edit
3

Note on documentation: "This function is the only method in HighGUI that can fetch and handle events, so it needs to be called periodically for normal event processing unless HighGUI is used within an environment that takes care of event processing." Since this is the only method, you are pretty much stuck.

unxnut gravatar imageunxnut ( 2014-02-05 15:26:15 -0600 )edit
-1

answered 2014-02-06 05:13:55 -0600

Wolf gravatar image

Try cv::startWindowThread() after opening the window with cv::namedWindows(). Makes your window more responsive if there is no waitKey around.....

edit flag offensive delete link more

Comments

this will not work 100 % of the time ... the interface is created for using with waitKey(). The interface openCV provides is mainly for debugging purposes. If you want a full blown GUI, you need to use QT or winforms or something like that.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-06 06:02:27 -0600 )edit

Question Tools

Stats

Asked: 2014-02-05 13:19:06 -0600

Seen: 34,247 times

Last updated: Feb 06 '14