Ask Your Question
0

Delay syntax in opencv (wait)

asked 2014-10-13 22:59:54 -0600

zms gravatar image

Hi all, It is quite funny I couldn't locate the syntax example on delay for opencv. For c++ normally the syntax would be delay_ms(200) and the coding will wait for 200ms before proceed to the next syntax.

Can anyone please help to direct me to the syntax.

Appreciate on everyone response. Thanks Zamani

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-10-15 08:32:34 -0600

Working C++ functions for both Windows and Linux. However do include the correct header files! Else it will never work.

#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS__) || defined(__TOS_WIN__)

  #include <windows.h>

  inline void delay( unsigned long ms )
    {
    Sleep( ms );
    }

#else  /* presume POSIX */

  #include <unistd.h>

  inline void delay( unsigned long ms )
    {
    usleep( ms * 1000 );
    }

#endif
edit flag offensive delete link more
0

answered 2014-10-14 02:28:15 -0600

You could use cv::waitKey(ms) but is there a reason you don't want to use the normal c++ functions?

edit flag offensive delete link more

Comments

1

Keep in mind that waitKey(ms) will ONLY work if there is a window opened. If not, it will compile just fine but never perform the wait. Better use the native c++ commands.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-10-14 05:35:39 -0600 )edit

that's the reason I think I do not use the waitkey.. the delay that I want to use is to make sure it delay for a few second before the next syntax is being executed. Is it still with waitkey?

Zamani

zms gravatar imagezms ( 2014-10-14 09:30:03 -0600 )edit
1

No I would use C++ delays then.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-10-15 04:11:10 -0600 )edit

Hi Steve... Can I know what is the syntax for opencv C++? I had tried delay_ms(), wait() but the syntax is just wrong. Can please help to share the synxtax with me?

thanks

zms gravatar imagezms ( 2014-10-15 08:28:13 -0600 )edit
1

syntax != statement

boaz001 gravatar imageboaz001 ( 2014-10-15 08:36:17 -0600 )edit

Hi boaz, what do u mean with the syntax? The syntax show not equivalent to something then do something.

is it related to delay?

zms gravatar imagezms ( 2014-10-16 03:02:25 -0600 )edit

@boaz001 your comment is totally irrelevant :D

StevenPuttemans gravatar imageStevenPuttemans ( 2014-10-16 03:13:41 -0600 )edit

@StevenPuttemans maybe irrelevant or maybe it is. An important aspect of programming is using the right terminology, to me it is a indicator of one's understanding of the problem or knowledge of programming. There is also a parallel with programming because it is a very strict skill, one single wrong character could give completely different result of your program - we've all experienced this ;). So read this and then this.

boaz001 gravatar imageboaz001 ( 2014-10-16 04:36:43 -0600 )edit

Lol you are going to give me a lesson in syntax versus statement considering is have a master of science in IT? Again, what brings your remark as an extra to the topic starters question? Except from he using a wrong concept word, and you pointing him on that, i do lot see the benefit of such remark without further explanation...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-10-16 05:41:01 -0600 )edit

Next time i'll use more explanation. And obviously the read was a more general comment that wasn't meant for you. And wow, a master of science in IT! Great!

boaz001 gravatar imageboaz001 ( 2014-10-16 07:03:59 -0600 )edit

Question Tools

Stats

Asked: 2014-10-13 22:59:54 -0600

Seen: 12,650 times

Last updated: Oct 15 '14