es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

No se puede capturar video con opencv en macOS.

Al usar Python para capturar video con open cv2, obtengo lo siguiente:

2021-11-18 11:07:36.572 Python[5863:20765] =>> Propiedad verificada: [cfen] 1667655022
2021-11-18 11:07:36.572 Python[5863:20765] =>> Propiedad verificada: [cfen] 1667655022
2021-11-18 11:07:36.572 Python[5863:20765] =>> Propiedad verificada: [cfen] 1667655022
2021-11-18 11:07:36.572 Python[5863:20765] =>> Propiedad verificada: [cfac] 1667653987
2021-11-18 11:07:36.621 Python[5863:20765] =>> Propiedad verificada: [cfen] 1667655022
2021-11-18 11:07:36.622 Python[5863:20765] =>> Propiedad verificada: [cfen] 1667655022
2021-11-18 11:07:36.722 Python[5863:20765] =>> Propiedad verificada: [cfen] 1667655022
2021-11-18 11:07:36.722 Python[5863:20765] =>> Propiedad verificada: [cfen] 1667655022

También se abre la siguiente ventana:

ventana

Este es mi código:


import cv2 datos_cara_entrenada = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') webcam = cv2.VideoCapture(0) ret, frame = webcam.read() img_escala_grises = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('Detector de caras en imagen', img_escala_grises) cv2.waitKey(1)
Tags:  ,

Answer

  1. Avatar for davy.ai

    Parece que estás intentando capturar video con OpenCV2 y estás obteniendo la siguiente salida:

    2021-11-18 11:07:36.572 Python[5863:20765] >>> Checked Property: [cfen] 1667655022
    2021-11-18 11:07:36.572 Python[5863:20765] >>> Checked Property: [cfen] 1667655022
    2021-11-18 11:07:36.572 Python[5863:20765] >>> Checked Property: [cfen] 1667655022
    2021-11-18 11:07:36.572 Python[5863:20765] >>> Checked Property: [cfac] 1667653987
    2021-11-18 11:07:36.621 Python[5863:20765] >>> Checked Property: [cfen] 1667655022
    2021-11-18 11:07:36.622 Python[5863:20765] >>> Checked Property: [cfen] 1667655022
    2021-11-18 11:07:36.722 Python[5863:20765] >>> Checked Property: [cfen] 1667655022
    2021-11-18 11:07:36.722 Python[5863:20765] >>> Checked Property: [cfen] 1667655022
    

    Además, se abre una ventana como se muestra en la imagen siguiente:

    ![window][1]

    Tu código se ve así:

    import cv2
    trained_face_data = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
    webcam = cv2.VideoCapture(0)
    ret, frame = webcam.read()
    grayscaled_img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.imshow('image face detector', grayscaled_img)
    cv2.waitKey(1)
    

    Es difícil decir cuál es el problema sin más información. Es posible que el código no esté funcionando como se espera debido a un problema con la biblioteca OpenCV2 o la cámara web. Es posible que desees intentar usar una cámara web diferente o actualizar la biblioteca OpenCV2 para ver si eso resuelve el problema.

Comments are closed.