python - OpenCV 2 raising exceptions on read() with different resolutions -
what might reasons of cv2.videocapture.read()
exception?
i have app shows live feed of camera (preview frames) , after button press takes snapshot higher resolution.
the preview frames, @ 640x360
read no problems, after running time starts raise exceptions whenever try retrieve image 1920x1080
resolution.
exception: null object passed py_buildvalue
.
ok
.set(3, 640) .set(4, 360)
error
.set(3, 1920) .set(4, 1080)
cam.read()
can't return false in tuple, crashes.
related code:
# timer self.timer = qtimer() self.timer.timeout.connect(self.__countdown) self.timer.start(100) def __countdown(self): self.__grabframe() if self.counter == 1: # show background image elif self.counter % 10 == 0: # show countdown on screen elif self.counter == 29: self.timer.stop() self.counter = 0 self.camcapture.set(3, 1920) self.camcapture.set(4, 1080) self.__takepicture() self.counter += 1 def __grabframe(self): # grab frame, transform image , display inside pixmap # used show video screen while counting down taking place frame = self.camcapture.read() image = qimage(frame[1].data, 640, 360, qimage.format_rgb888).rgbswapped()#.mirrored(true, false) self.pixmap = qpixmap.fromimage(image) self.background.setpixmap(self.pixmap) def __takepicture(self): # grab frame, transform image , display inside pixmap try: frame = self.camcapture.read() self.logger.info("[takepicture] retval camcapture.read(): {0}".format(str(frame[0]))) image = qimage(frame[1].data, 1920, 1080, qimage.format_rgb888).rgbswapped() pixmap = qpixmap.fromimage(image) self.pixmap = pixmap except exception e: self.logger.error("[takepicture] {0}".format(str(e)))
Comments
Post a Comment