Ask Your Question
0

TypeError: images is not a numerical tuple

asked 2018-03-01 16:47:01 -0600

TacoTuesday gravatar image

updated 2018-03-02 01:19:57 -0600

Hello all,

I'm an OpenCV nube and am pretty clueless about writing the code currently. I found this code and adapted it to my needs but keep getting this compiling error. I've been troubleshooting it for over three days now and am about to go insane. So that's why I'm hoping anyone can help me.

I'm trying to stitch together two video feeds and am able to successfully get the feeds to work independently.

The following is my error:

     Traceback (most recent call last):
      File "cameraStitching.py", line 26, in <module>
        result = stitcher.stitch([left, right])
TypeError: images is not a numerical tuple

Here is my code:

 #!/usr/bin/env python

 from __future__ import print_function
 import stitcher
 #from imutils.video import VideoStream

 import numpy as np
 import datetime
 #import imutils
 import time
 import cv2
 import sys

 print("[INFO] starting cameras...")
 leftStream = cv2.VideoCapture("nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")
 rightStream = cv2.VideoCapture("nvcamerasrc sensor-id=2 ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")
 time.sleep(2.0)

 stitcher = cv2.createStitcher(False)
 total = 0

 while True:
         left = leftStream.read()
         right = rightStream.read()

         result = stitcher.stitch([left, right])

         if result is None:
                 print("[INFO] homography could not be computed")
                 break

         total += 1
         timeStamp = datetime.datetime.now()
         ts = timestamp.strftime("%A %d %B %Y %I:%M:%S%p")
         cv2.putText(result, ts, (10, result.shape[0] - 10),
                 cv2.FONT_HERSHEY_SIMPLEX, 0.35, (0, 0, 255), 1)

         cv2.imshow("result", result)
         cv2.imshow("left frame", left)
         cv2.imshow("right frame", right)
         key = cv2.waitKey(1) & 0xFF

         if key == ord("q"):
                 break

 print("[INFO] cleaning up...")
 cv2.destroyAllWindows()
 leftStream.stop()
 rightStream.stop()

THanks for any and all help & direction you may point me in.

edit retag flag offensive close merge delete

Comments

as long as folks here can't try your code, you won't get an answer. please try again, without line numbers.

berak gravatar imageberak ( 2018-03-01 23:28:23 -0600 )edit

Thanks for the tip.

TacoTuesday gravatar imageTacoTuesday ( 2018-03-02 01:20:17 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-03-02 05:47:44 -0600

berak gravatar image

https://docs.opencv.org/master/d2/d8d...

both VideoCapture.read() and Stitcher.stitch() return a tuple of results. you need code like this:

left_img, left_ok = leftStream.read()
right_img, right_ok = leftStream.read()

if not left_ok:
    print("left cam failed")
    return

if not right_ok:
    print("right cam failed")
    return

status, result = stitcher.stitch([left_img, right_img])
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-03-01 16:47:01 -0600

Seen: 11,716 times

Last updated: Mar 02 '18