-2

I'm trying to work with ArUco markers using OpenCV in python.

vidcap = cv2.VideoCapture(0)
vidcap.set(cv2.CAP_PROP_BUFFERSIZE, 1)
c = np.array(np.zeros([9,4,2]))
while vidcap.isOpened():
exists,image = vidcap.read()
if exists:
    image = cv2.resize(image, (1200, 800))
    arucodict = aruco.Dictionary_get(aruco.DICT_6X6_50)
    arucoparams = aruco.DetectorParameters_create()
    (corners, id, rejected) = aruco.detectMarkers(image, arucodict, parameters=arucoparams)
    for (a,b) in zip(corners,id):
        if b in range(0,10):
            c[b-1]=a

The for statement is throwing an error for (a,b) in zip(corners,id): TypeError: 'NoneType' object is not iterable

What am I doing wrong?

JIRAIYA
  • 1
  • 2
  • always put full error message (starting at word "Traceback") in question (not comment) as text (not screenshot, not link to external portal). There are other useful information. – furas May 20 '21 at 21:10
  • 1
    if error shows you which line makes problem then first you could use `print()`, `print(type())` to check what you have in variables. It seems you have `None` in `corners` or `id` and only you can check it using `print()`. And when you will know which variable has `None` then you have to check code which gives this `None` - `detectMarkers` - and you will have to figure out why it gives `None`. We don't have your data, we can't run your code so we can't check why it gives `None`. – furas May 20 '21 at 21:13

1 Answers1

0

If vidcap is giving you the same input data as I am (since I do not know what you are looking for in the image) you are more than likely trying to work on an empty list; specifically corners. I added a check for that:

vidcap.set(cv2.CAP_PROP_BUFFERSIZE, 1)
c = np.array(np.zeros([9,4,2]))
while vidcap.isOpened():
    exists,image = vidcap.read()
    if exists:
        image = cv2.resize(image, (1200, 800))
        arucodict = aruco.Dictionary_get(aruco.DICT_6X6_50)
        arucoparams = aruco.DetectorParameters_create()
        (corners, id, rejected) = aruco.detectMarkers(image, arucodict, parameters=arucoparams)
        if corners:
            for (a,b) in zip(corners,id):
                if b in range(0,10):
                    c[b-1]=a
Shawn Ramirez
  • 796
  • 1
  • 5
  • 10