You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FileVideoStream Problem: FATAL: exception not rethrown Aborted (core dumped) #38
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?
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
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()
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.
Activity
jrosebr1 commentedon Sep 22, 2017
What was your error and/or traceback?
msz89 commentedon Jan 11, 2018
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
jrosebr1 commentedon Jan 11, 2018
Can you confirm that this is an OpenCV issue an not related to your
sql_uppermodule? If not, this might be a threading issue. Try:And see if the additional sleep allows the threads to close properly.
msz89 commentedon Jan 11, 2018
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
VideoStreamto 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
videostreamcreates awebcamvideostreamclass object.Wrt. the
WebcamVideoStreamobject 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
I should have mentioned this is happening when I try to
quit()from the script, or the abovebreakcauses the flow to leave the mainwhileloop and run its course through to the end of the script.This error is happening upon exit.
Would a change the
.updateinWebcamVideoStreamhelp?This would make the Thread non-Daemon just before it stops...
...or could other issues by the Thread being non Daemon
jrosebr1 commentedon Jan 11, 2018
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.
lukasbrchl commentedon Aug 29, 2018
@knaffe I fixed this in #86
jrosebr1 commentedon Oct 29, 2018
Resolved by merging in #86.