OpenCV Crashes when reopening camera on Mac OSX Sierra and displaying -
when reopen webcam in opencv on mac osx sierra, , display images it, nsexceptions.
this test code i'm working try figure out error mode.
import cv2 cam = cv2.videocapture(0) ret, im = cam.read() cv2.imshow('im', im) cv2.waitkey(1) cam.open(0) ret, im = cam.read() cv2.imshow('im', im) cv2.waitkey(1) cam.open(0) ret, im = cam.read() cv2.imshow('im', im) cv2.waitkey(1) cam.open(0) ret, im = cam.read() cv2.imshow('im', im) cv2.waitkey(1)
the error i'm getting is
2016-11-05 18:15:07.075 python[1082:24157] *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'an instance 0x7fca4ac3a6f0 of class avcapturedaldevice deallocated while key value observers still registered it. current observation info: <nskeyvalueobservationinfo 0x7fca4ac42f80> ( <nskeyvalueobservance 0x7fca4ae6df50: observer: 0x7fca4ae6b410, key path: open, options: <new: no, old: no, prior: no> context: 0x7fffc9c99570, property: 0x7fca4ac3fe30> )' *** first throw call stack: ( 0 corefoundation 0x00007fffafde96fb __exceptionpreprocess + 171 1 libobjc.a.dylib 0x00007fffc45f0a2a objc_exception_throw + 48 2 corefoundation 0x00007fffafe669a5 +[nsexception raise:format:] + 197 3 foundation 0x00007fffb17d1d84 nskvodeallocate + 293 4 avfoundation 0x00007fffac67dabe -[avcapturedeviceinput _setdevice:exceptionreason:] + 304 5 avfoundation 0x00007fffac5ae914 -[avcapturedeviceinput dealloc] + 39 6 corefoundation 0x00007fffafe53a7b -[__nssingleobjectarrayi dealloc] + 43 7 libobjc.a.dylib 0x00007fffc45e5e60 _zn12_global__n_119autoreleasepoolpage3popepv + 808 8 corefoundation 0x00007fffafd20d66 _cfautoreleasepoolpop + 22 9 corefoundation 0x00007fffafd612c5 __cfrunlooprun + 2229 10 corefoundation 0x00007fffafd607b4 cfrunlooprunspecific + 420 11 hitoolbox 0x00007fffaf2fcfbc runcurrenteventloopinmode + 240 12 hitoolbox 0x00007fffaf2fcdf1 receivenexteventcommon + 432 13 hitoolbox 0x00007fffaf2fcc26 _blockuntilnexteventmatchinglistinmodewithfilter + 71 14 appkit 0x00007fffad9e6b79 _dpsnextevent + 1093 15 appkit 0x00007fffae0fc1c3 -[nsapplication(nsevent) _nexteventmatchingeventmask:untildate:inmode:dequeue:] + 1637 16 libopencv_highgui.2.4.dylib 0x000000010d79c0a6 cvwaitkey + 402 17 cv2.so 0x000000010cfa3ce1 _zl16pyopencv_waitkeyp7_objects0_s0_ + 103 18 python 0x000000010cc001ab pyeval_evalframeex + 27003 19 python 0x000000010cbf963a pyeval_evalcodeex + 1617 20 python 0x000000010cbf8fe3 pyeval_evalcode + 48 21 python 0x000000010cc1cc04 run_mod + 53 22 python 0x000000010cc1cca7 pyrun_fileexflags + 133 23 python 0x000000010cc1c7f8 pyrun_simplefileexflags + 702 24 python 0x000000010cc2deba py_main + 3094 25 libdyld.dylib 0x00007fffc4ecd255 start + 1 26 ??? 0x0000000000000002 0x0 + 2 ) libc++abi.dylib: terminating uncaught exception of type nsexception abort trap: 6
i error consistently when run iterm or terminal. inconsistently xterm.
i same error when using cam.release()
prior calls cam.open(0)
.
import cv2 cam = cv2.videocapture(0) ret, im = cam.read() cv2.imshow('im', im) cv2.waitkey(1) cam.release() cam.open(0) ret, im = cam.read() cv2.imshow('im', im) cv2.waitkey(1) cam.release() cam.open(0) ret, im = cam.read() cv2.imshow('im', im) cv2.waitkey(1) cam.release() cam.open(0) ret, im = cam.read() cv2.imshow('im', im) cv2.waitkey(1) cam.release()
in cap_avfoundation_mac.mm
, function cvcapturecam::stopcapturedevice
, comment line:
[mcapturedevice release];
Comments
Post a Comment