简体   繁体   English

zsh:非法硬件指令 mediapipe 和 openCV 错误

[英]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.我在 M1 Mac 64 位 Ventura 13.2 上使用 python 3.8.0,使用 VsCode 和最新版本的 openCv、Mediapipe 和 numpy。我尝试了不同的 IDE,但没有成功。

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.我运行了几次,然后通过 HDMI 将我的笔记本电脑连接到内置摄像头的电视,然后断开我的笔记本电脑与电视的连接,现在我的代码不起作用。 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.我尝试将 the.VideoCapture() 中的参数从 -10 更改为 10,但仍然没有成功。

This seems to be a problem caused by the M1 CPU.这似乎是M1 CPU的问题。 You need to compile OpenCV by yourself or download a compiled OpenCV by others for M1. M1需要自己编译OpenCV或者下载别人编译好的OpenCV。 Then the mediapipe for sure. 然后是媒体管道 Welcome to the world of Mx CPU.欢迎来到 Mx CPU 的世界。

I had conflicting packages.我有冲突的包裹。 I installed a bunch of packages via homebrew and pip3.我通过 homebrew 和 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. OpenCv 现在可以使用,但我无法为我的 M1 mac 安装 mediapipe 或 mediapipe-silicon。 If I fix this, I will let everyone know.如果我解决了这个问题,我会让所有人都知道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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