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

[Python] Retornar porcentagem de marrom na imagem

Discussão em 'Python' iniciado por Stack, Outubro 5, 2024 às 22:52.

  1. Stack

    Stack Membro Participativo

    Tenho um código em que pego um vídeo e salvo uma imagem a cada 20 frames e pego uma fatia dessa imagem, até ai consegui fazer, mas preciso analisar se possuem pixeis com tom igual ou mais escuro de marrom que esse: RGB 194, 187, 138 e não tenho ideia de como fazer isso, como detectar porcentagem da cor marrom com esse RGB especifico?

    Esse é meu código até agora

    import cv2
    import os
    import numpy as np

    # Read the video from specified path
    cam = cv2.VideoCapture("D:/outpy.avi")

    currentframe = 0
    x = 20
    while(True):

    # reading from frame
    ret,frame = cam.read()

    if ret:
    # if video is still left continue creating images
    name = 'D:/' + str(currentframe) + '.png'
    print ('Creating...' + name)

    # writing the extracted images
    if currentframe == x:
    cv2.imwrite(name, frame)
    imagem = cv2.imread("D:/{}.png".format(x))
    fatia = imagem[0:150, 150:300]


    x = x + 20
    if cv2.waitKey(25) & 0xFF == ord('q'):
    break

    # increasing counter so that it will
    # show how many frames are created
    currentframe += 1
    else:
    break

    # Release all space and windows once done
    cam.release()
    cv2.destroyAllWindows()

    Continue reading...

Compartilhe esta Página