【问题标题】:OpenCV 3 Python 3.5 AnacondaOpenCV 3 Python 3.5 蟒蛇
【发布时间】:2016-11-02 01:41:43
【问题描述】:

我尝试在 anaconda 虚拟环境中安装 opencv 3。我使用了以下 binstar 包..

conda

source activate (envname)

conda install -c https://conda.binstar.org/menpo opencv

conda list 

cv__version__ 也给出了正确的输出 3.1.0

这是我的第一个示例代码

 import numpy as np
 import cv2

cap = cv2.VideoCapture(0)

  while(True):
# Capture frame-by-frame
ret, frame = cap.read()

# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
    break

# When everything done, release the capture
 cap.release()
 cv2.destroyAllWindows()

我在运行 ./fp.py: line 1: import: command not found 时收到以下错误 ./fp.py:第 2 行:导入:找不到命令 ./fp.py:第 4 行:意外标记附近的语法错误 (' ./fp.py: line 4:cap = cv2.VideoCapture(0)'

每当我使用导入视频作为视频时,我都会收到错误消息:找不到视频模块。我认为这与我下载的 binstar 包中不存在 ffmpeg 有关。

【问题讨论】:

  • 请查看minimal reproducible example 并相应地编辑您的问题。我们无法按原样回答您的问题。
  • 对编辑有帮助吗
  • 请再次查看此段:Describe the problem. "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Put a brief summary of the problem in the title of your question.
  • 完成!我也添加了使用的示例代码

标签: python ffmpeg anaconda opencv3.0 python-3.5


【解决方案1】:

通常,您应该运行“python fp.py”而不是 ./fp.py。

. command 将在当前 shell 中运行 bash-script(xxx.sh),python xxx.py 将运行 python 文件。

享受吧!

【讨论】:

  • 当我使用导入视频作为视频时,我得到错误视频模块未找到。这是我下载的 binstar 包中没有 ffmpeg 的问题!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-04
  • 2017-02-24
  • 2010-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-21
相关资源
最近更新 更多