I have 2 cameras (1 - Kayeton KYT-U200-R01 and 2 - similar one but for IR) running on my Raspberry Pi 3. Everything worked fine but suddenly after resolution has been changed from 640x480 to 1024x768 on both the second camera refused to work. The error I get switching over to the second camera is as follows:

error: (-215) total() == 0 || data != __null in function Mat

Even after restoring previous resolution and system reboot the second camera won't work. If someone came across this issue before, please write your solution, thanks in advance.

Here is my Python code:

Camera initialization

def init_cameras(self):
    self.cap_1 = cv2.VideoCapture(1)
    self.cap_1.set(cv2.CAP_PROP_FPS, 1)

    # set resolution
    self.cap_1.set(3, 640)
    self.cap_1.set(4, 480)

    self.cap_2 = cv2.VideoCapture(0)
    self.cap_2.set(cv2.CAP_PROP_FPS, 1)

    # set resolution
    self.cap_2.set(3, 640)
    self.cap_2.set(4, 480)

Frame reading

def get_img_frame_from_camera_two(self):
    ret, img_frame = self.cap_2.read()
    # to save it when 'capture' button will be clicked

    qFormat = QtGui.QImage.Format_RGB888

    img_frame = QtGui.QImage(img_frame, img_frame.shape[1], img_frame.shape[0], img_frame.strides[0], qFormat)
    img_frame = img_frame.rgbSwapped()

    return img_frame

Run method of separate thread to read the frame

def run(self):
            img_frame = self.camera_manager.get_img_frame_from_camera_two()
            frame = {}
            frame['img'] = img_frame
                if self.camera_manager.queue_frames_camera_two.qsize() < 10:
                    # put frame to queue
                    # notify listener on new frame added in

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.