简体   繁体   中英

zsh: illegal hardware instruction mediapipe and openCV error

I keep running into this error and can't fix it. I spoke with many people and they are not sure what to do. My code is below. This is very simple code that should open my webcam and display the live video. I am using python 3.8.0 on a M1 Mac 64 bit Ventura 13.2 using VsCode with the latest version of openCv, Mediapipe, and numpy. I have tried different IDE's and no luck.

import cv2
import mediapipe as mp
import numpy as np

mp_drawing = mp.solutions.drawing_utils
mp_pose = mp.solutions.pose

#VIDEO FEED
cap = cv2.VideoCapture(0)
while cap.isOpened():
    ret, frame = cap.read()
    cv2.imshow('Mediapipe Feed', frame)
    
    if cv2.waitKey(10) & 0xFF == ord('q'):
        break
        
cap.release()
cv2.destroyAllWindows()

I got this code to work the first time I ran it. I ran it a few times, then connected my laptop via HDMI to a TV that has a camera built into it and then disconnected my laptop from the TV and now my code doesn't work. I think it has something to do with not being able to find the camera on my laptop but I can't figure it out. Any help would be great. I have tried changing the argument inside the.VideoCapture() from -10 to 10 and still no luck.

This seems to be a problem caused by the M1 CPU. You need to compile OpenCV by yourself or download a compiled OpenCV by others for M1. Then the mediapipe for sure. Welcome to the world of Mx CPU.

I had conflicting packages. I installed a bunch of packages via homebrew and pip3. I installed everything I am not using or going to use and that solved the issue. OpenCv works now, but I can't install mediapipe or mediapipe-silicon for my M1 mac. If I fix this, I will let everyone know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM