Skip to content

FileVideoStream Problem: FATAL: exception not rethrown Aborted (core dumped) #38

Closed

Description

@knaffe

Code:

fvs = FileVideoStream("./1_2017-03-17_08-38-27.mp4")
fvs.start()
num = 0
while fvs.more():
frame = fvs.read()
if frame is None:
print("Break!")
break
print(num)
num = num +1
print("finished!")
fvs.stop()

First, It wouldn't print the number, that means fvs.more() doesn't work.
And it would raise a ERROR at last.
Notice, the path of video is on the way.
How can I deal with my problem?

Activity

  1. jrosebr1 commented on Sep 22, 2017

    @jrosebr1
    Contributor

    What was your error and/or traceback?

  2. msz89 commented on Jan 11, 2018

    @msz89

    Adrian, I'm getting a similar error:

    FATAL: exception not rethrown
    Aborted (core dumped)

    I've opened two webcam streams, and it happens when I try break from my main while loop

        webcam1 = VideoStream(src=0, framerate=framerate).start()
        webcam2 = VideoStream(src=1, framerate=framerate).start()
    
        while True:
            total = 0
            print('[INFO] Starting bullet time...')
            label = input('[INFO] Enter label for video [q to quit]: ')
            if label in ["q","Q"]:
                cv2.destroyAllWindows()
                print('[INFO] Compressing folders into tar')
                sql_upper.make_tar_from_list('test.tar.gz', list_to_compress)
                webcam1.stop()
                webcam2.stop()
                break ##ERROR THROWN HERE
    
  3. jrosebr1 commented on Jan 11, 2018

    @jrosebr1
    Contributor

    Can you confirm that this is an OpenCV issue an not related to your sql_upper module? If not, this might be a threading issue. Try:

    import time
    time.sleep(3.0)
    webcam1.stop()
    webcam2.stop()
    

    And see if the additional sleep allows the threads to close properly.

  4. msz89 commented on Jan 11, 2018

    @msz89

    Thanks for your quick response.
    I tried putting the sleep in (and commenting out my other functions) but to no avail.

    Is there anything else that needs to happen to get the VideoStream to close off the resources its using.
    A bit of google suggests that the 'Exception not rethrown' is often associated with C++ and threading - I immediately thought CV2.

    From what I understand videostream creates a webcamvideostream class object.
    Wrt. the WebcamVideoStream object we have made:
    Calling the .start() method creates a Thread and kicks off the .update() class method.
    Update loops continuously until self.stopped == True (which happens when the .stop() method is called on our stream.

    I'm not an expert on threading, but is there a need to close of the thread t = Thread(target=self.update, args=()) that we create in the .start() method?
    Could this be where the resources are held up?

    I'm happy to provide more info about my use case.

    Thanks again, we're getting a lot out of your book!
    Matt

    PS. I had a peek a threading and found this note

    Daemon threads are abruptly stopped at shutdown. Their resources (such as open files, database transactions, etc.) may not be released properly. If you want your threads to stop gracefully, make them non-daemonic and use a suitable signalling mechanism such as an Event.

    I should have mentioned this is happening when I try to quit() from the script, or the above break causes the flow to leave the main while loop and run its course through to the end of the script.
    This error is happening upon exit.

    Would a change the .update in WebcamVideoStream help?
    This would make the Thread non-Daemon just before it stops...
    ...or could other issues by the Thread being non Daemon

        def update(self):
    		# keep looping infinitely until the thread is stopped
    		while True:
    			# if the thread indicator variable is set, stop the thread
    			if self.stopped:
                                    **t.daemon = False**
    				return
    
    			# otherwise, read the next frame from the stream
                     (self.grabbed, self.frame) = self.stream.read()
    
  5. jrosebr1 commented on Jan 11, 2018

    @jrosebr1
    Contributor

    I'm not an expert on threading, but is there a need to close of the thread t = Thread(target=self.update, args=()) that we create in the .start() method?
    Could this be where the resources are held up?

    This is very likely what is causing the problem here. The thread is likely not being cleaned up. In my use cases it seems that the thread is being properly collected, but somewhere our use cases deviate and yours is not exiting properly.

    Unfortunately I'm not sure where the exact error is. I think you're on the right track though. Take a look at the comments section of these blog posts where threading is utilized:

    I know readers have mentioned having threading problems before (specifically on exit) but we haven't been able to pinpoint exactly where the issue is. Threading can be a bit of a bear. If we diagnose and resolve the issue I'd be happy to update the library.

  6. lukasbrchl commented on Aug 29, 2018

    @lukasbrchl
    Contributor

    @knaffe I fixed this in #86

  7. jrosebr1 commented on Oct 29, 2018

    @jrosebr1
    Contributor

    Resolved by merging in #86.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions