问题描述
我正在运行Mac OS X(10.14.4),并尝试遵循YouTube教程; https://www.youtube.com/watch?v=bDaxeg4HKQY ;使用Python + openCV的YOLO v2过程视频进行图像检测
I'm running Mac OS X (10.14.4) and I'm attempting to follow YouTube tutorial; https://www.youtube.com/watch?v=bDaxeg4HKQY; Image Detection with YOLO v2 Process Video in Python + openCV
在UNIX终端中,我可以执行以下操作:
In a UNIX Terminal I'm able to do the following:
-
配置虚拟环境并激活它;
source activate tensorvid
运行python脚本以设置必要的依赖项 python3 setup.py build_ext --inplace
Run a python script to setup the necessary dependenciespython3 setup.py build_ext --inplace
成功运行python脚本 python video_processing.py
Run a python script successfullypython video_processing.py
这是video_processing.py的初始代码:
Here is the initial code present video_processing.py:
import cv2
from darkflow.net.build import TFNet
import numpy as np
import time
option = {
'model': 'cfg/yolo.cfg',
'load': 'bin/yolo.weights',
'threshold': 0.15
}
#tfnet = TFNet(option)
capture = cv2.VideoCapture('CallOnMe.mp4')
colors = [tuple(255 * np.random.rand(3)) for i in range(5)]
for color in colors:
print(color)
这是终端中显示的正确输出:
Here is the correct output shown in the Terminal:
(204.81913044109854, 251.10740779370366, 179.94942134863612)
(252.91320724585321, 180.778985117877, 190.80678674396898)
(192.82964108641886, 186.81635896070537, 9.692333421690345)
(88.90586768830556, 33.25890210180309, 201.9617662283273)
(71.27947539601615, 253.32836287511097, 171.81978416084678)
但是,当我在Mac上使用ATOM尝试上述操作时,出现以下错误:
However, when I try the above using ATOM for Mac I receive the following error:
Traceback (most recent call last):
File "/Users/macuser/darkflow-master/video_processing.py", line 1, in <module>
import cv2 ModuleNotFoundError: No module named 'cv2'
在Atom中:
-
我已经使用'Virtualenv'创建了一个虚拟环境并将其命名为'tensorvid'
I've created a virtual environment using 'Virtualenv' and named it 'tensorvid'
我尝试使用配置脚本"配置脚本",但这似乎不起作用
I've tried to configure the 'script' using 'configure script' but that doesn't seem to work
有人知道如何使用给定的UNIX命令配置Atom吗?
Does anyone know how to configure Atom with the UNIX commands given so it works please?
推荐答案
我相信我已经回答了自己的问题.
I believe I have an answer to my own question.
我只是通过Atom->首选项->程序包
I simply installed the 'Hydrogen' package via Atom --> Preferences --> Packages
现在,我可以启动一个虚拟环境并在Atom应用程序中对其进行控制.
Now I can start a virtual environment and control it all within the Atom application.
问题已解决:-)
这篇关于运行python脚本时Atom显示ModuleNotFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!