[Solved] Weird camera frame

For the vision system, we sometimes get a weird frame of the camera. Does anyone know what the issue might be that causes that? I didn’t have that issue before when testing out the vision system, but now it comes more frequently and messes up with the vision part.

Using a logitech webcam for the frame capture. Without going through the vision part, it shows that messed up frame already.
Also connected the webcam through an extension cable to the upboard, we tried using a different extension cable, but it still comes up. (Using an extension cable because it’s not long enough to route it to the upboard).

How long is the extension cable and is it active (a USB booster build-in) or passive?

Please share your code and the model of the webcam.

The extension cable is 3 meters long, not sure if it has an active USB Booster built-in or not, not sure how to see/check that too.

The code to get the frame is:

def get_frame():
cap = cv2.VideoCapture(1)
ret, img = cap.read()
frame = cv2.flip(img,-1)
cap.release()
return frame

Model of the webcam: Logitech HD Webcam V-U0018 (C270)

I see the problem. You are connecting and disconnecting to the camera for each frame. You should connect to the camera at the initialization of your code, and rewrite the function to:

Edit: You might want to add a warmup period at the start of your code

def get_frame():
    ret, img = cap.read()
    frame = cv2.flip(img,-1)
    return frame

cap = cv2.VideoCapture(1)

for i in range(30):
    get_frame()

while True:
    newframe = get_frame()
    #Whatever you need to do

cap.release()

edit 2: Solved!