zoukankan      html  css  js  c++  java
  • 使用Python的opencv-python调用摄像头

    先上代码,注意使用python3运行

    #!/usr/bin/env python3
    # coding=utf-8
    from cv2 import cv2
    cap = cv2.VideoCapture(0)
    while True:
        ret, frame = cap.read()
        cv2.imshow('frame', frame)
        c = cv2.waitKey(1)
        if c == ord('q'):
            break
    cap.release()
    cv2.DestroyAllWindows()

    注意依赖安装顺序:

    1.先安装

    sudo apt-get install libgtk2.0-dev
    sudo apt-get install pkg-config

    2.再安装

    pip3 install opencv-python

    如果已经安装过,并且提示错误,则使用以下命令安装

    pip3 uninstall opencv-python

    pip3 --no-cache-dir install opencv-python

    如果没有进行第一步安装,直接安装opencv-python会出现以下错误:

    The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function
  • 相关阅读:
    软件工程第1次阅读作业
    软件工程第0次作业
    OO第四次博客
    OO第三次总结
    OO第二次总结
    OO第一次总结
    提问回顾与个人总结
    结对项目:最长单词链
    第一次阅读作业
    第四次博客
  • 原文地址:https://www.cnblogs.com/guanglin/p/14086972.html
Copyright © 2011-2022 走看看