1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] read three basic colors with camera detects three colors. Errors in screen

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    explain these error from this code?

    import numpy as np import cv2

    taking the input from webcam


    vid = cv2.VideoCapture(0)

    running while loop just to make sure that

    our program keeps running until we stop it



    while True: # capturing the current frame _, frame = vid.read()

    # displaying the current frame
    cv2.imshow("frame", frame)

    # setting values for base colors
    b = frame[:, :, 0] # Blue channel
    g = frame[:, :, 1] # Green channel
    r = frame[:, :, 2] # Red channel

    # computing the mean
    b_mean = np.mean(b)
    g_mean = np.mean(g)
    r_mean = np.mean(r)

    # displaying the most prominent color
    if b_mean > g_mean and b_mean > r_mean:
    print("Blue")


    elif g_mean > r_mean and g_mean > b_mean: print("Green") else: print("Red")

    # breaking the loop if 'q' is pressed
    if cv2.waitKey(1) & 0xFF == ord('q'):
    break


    this is screen output:

    Corrupt JPEG data: 3 extraneous bytes before marker 0xd3 Green Corrupt JPEG data: 1 extraneous bytes before marker 0xd6 Green Corrupt JPEG data: 4 extraneous bytes before marker 0xd0 Green Corrupt JPEG data: 5 extraneous bytes before marker 0xd1 Green Corrupt JPEG data: 1 extraneous bytes before marker 0xd6

    What are these errors?

    to find the file "I cant recall" to edit out the code and save it?

    Also why does the output show "Green" when the camera is pointed down and sitting on top of the pc case with the camera covered by the top cover of the pc?

    ?

    Continue reading...

Compartilhe esta Página