zoukankan      html  css  js  c++  java
  • 树莓派3B+SimpleCV上连接iPhone4s摄像头

    目的:把iPhone4s当成网络摄像头,通过wifi连接到树莓派上,做为树莓派的摄像头。

    1. iPhone4s上安装mini WebCam应用。

    很旧的一个app, 没有密码,简单,无广告,免费。
    启动WebCam服务, ip地址为192.168.1.222。

    2. 树莓派上运行代码

    代码:
    # url-cam.py

    from SimpleCV import JpegStreamCamera, Image,Display
    display = Display()
    # 连接iPhone4s网络摄像头
    cam = JpegStreamCamera('http://192.168.1.222/video.mjpg')
    while True:
        # 取网络摄像头图像
        img = cam.getImage()
        # 显示
        img.save(display)
    

    运行:
    :~$ pyhton url-cam.py

    错误:

    ERROR:
     24 Traceback (most recent call last):
     25   File "mobile-cam.py", line 7, in <module>
     26     img = cam.getImage()
     27   File "/home/pi/Code/SimpleCV/SimpleCV/Camera.py", line 1193, in getImage
     28     return Image(pil.open(StringIO(self.camthread.currentframe)), self)
     29   File "/home/pi/Code/SimpleCV/SimpleCV/ImageClass.py", line 1102, in __init    __
     30     cv.SetData(self._bitmap, self._pil.tostring())
     31   File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 697, in tostrin    g
     32     "Please call tobytes() instead.")
     33 NotImplementedError: tostring() has been removed. Please call tobytes() instead.
    

    3. 解决

    按错误要求修改ImageClass.py文件中1102行修改为1103行内容:

    1102  #cv.SetData(self._bitmap, self._pil.tostring())
    1103  cv.SetData(self._bitmap, self._pil.tobytes()) # changed tobytes() by hyper99
    
    

    截屏如下:

    simplecv

  • 相关阅读:
    产品微谈
    SVN回滚机制
    super究竟是个啥?
    PM12条
    CocoaPods初体验
    UIView局部点击
    Memory cycles about Block
    About "self"
    openfire学习(一)
    WPF菜单和布局(2)
  • 原文地址:https://www.cnblogs.com/hyper99/p/shu-mei-pai3BSimpleCV-shang-lian-jieiPhone4s-she-x.html
Copyright © 2011-2022 走看看