How to use return value of a function as condition of while that returns tuple in python -


I was looking for something like this but I did not know that it goes here.

Some backgrounds

I use opencv to get the frame from a video file. Usually people do this in the endless loop:

  while (true): s, img = cv.read ()   

or

  for i in xrange (10000): # large number, img = cv.read ()   

Now I want to recover all frames and loop I want to leave when there is no other frame, though my skills in dragon is not enough which I want to do.

What I want to know

read function (or method, I do not know how they are called in Python ) A tube gives: First represents the success of the operation, and the second frame returns the frame when I want to break the loop when the first element of tuple is false. Being a background, I thought it would work:

  while ((success, img = capture. Read ()) [0]): # sdh with img   

I thought it would break the loop when success would be false but it was not. Then I thought it would work:

  while ((success, IMG = Capture.Red). Success: #Ads with IMG   

It also did not work. I do not want to do anything like that (while): s, i = capture.read () if (s == wrong): break < / Pre>

How can test the status of in , a if breaks if it does not succeed? < P>

best to think of dragon Do not forget other languages ​​

  s = true while s: s, i = capture.read () if S: do_some_stuff (i)    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -