September 19
I'm pretty new to python and this code is for object detection, it works fine on my webcam but has an error when using an external camera This is what I have:

for classId, confidence,box in zip(classIds.flatten(),confs.flatten(),bbox):
        cv2.rectangle(img,box,color=(0,255,0),thickness=2)
        cv2.putText(img,classNames[classId-1].upper(),(box[0]+10,box[1]+30),
                    cv2.FONT_HERSHEY_COMPLEX,1,(0,255,0),2)
Here's the message I got:

Traceback (most recent call last):
  File "C:/Users/byeo9/PycharmProjects/FYP-ENV/Testing 2.py", line 31, in <module>
    for classId, confidence,box in zip(classIds.flatten(),confs.flatten(),bbox):
AttributeError: 'tuple' object has no attribute 'flatten'
September 19
On Saturday, 19 September 2020 at 06:10:47 UTC, selenanur wrote:
> I'm pretty new to python and this code is for object detection, it works fine on my webcam but has an error when using an external camera This is what I have:
>
> for classId, confidence,box in zip(classIds.flatten(),confs.flatten(),bbox):
>         cv2.rectangle(img,box,color=(0,255,0),thickness=2)
>         cv2.putText(img,classNames[classId-1].upper(),(box[0]+10,box[1]+30),
>                     cv2.FONT_HERSHEY_COMPLEX,1,(0,255,0),2)
> Here's the message I got:
>
> Traceback (most recent call last):
>   File "C:/Users/byeo9/PycharmProjects/FYP-ENV/Testing 2.py", line 31, in <module>
>     for classId, confidence,box in zip(classIds.flatten(),confs.flatten(),bbox):
> AttributeError: 'tuple' object has no attribute 'flatten'

Hello,

This forum is about the D programming language.
So I'm not sure you'll find any right answer here.

From a cursory glance, it seems your external camera doesn't lead to detection and as a result classIds is an empty tuple, or some null value. And as such doesn't enjoy having a .flatten() method.

(This is the sort of situation that static types were meant to avoid.)