在OS-X中开发Raspberry Pi相机应用



我想为Raspberry Pi上的基于相机的应用程序做一些Python Dev。我进行PY开发的普通模式是使用我的Apple Mac笔记本电脑来测试想法和emacs编写所得代码。通常,将与詹金斯一起部署到生产环境中的任何产生的工件。

但是,这是我第一次使用Raspberry Pi,上述模式尚未工作。即使安装pycamera库也在虚拟env中失败。

我想知道,在OSX上嘲笑Raspberry Pi硬件有图案吗?Linux开发人员如何在R.PI上工作?

这可能要晚一些,但是可以在PI上安装Jupyter并直接从Mac上的浏览器开发。

如果您有PI 2或3(或其他包括ARM7(,则可以安装Miniconda:https://gist.github.com/simoncos/a7ce35babeaf73f512be24135c0fbafb

如果您希望为Python 2安装Miniconda,则简单地称为" Miniconda-linux-arm7l.sh"。

还有一个名为berryconda的版本,它似乎支持PI的早期ARM6口味:https://github.com/jjhelmus/berryconda

我去了Miniconda的PI3路线,但是对于PI零,我粘在系统pythons上,并有很多打电话给PIP和PIP3。

双向完成,我认为我更喜欢依靠系统python。特别是用于专用使用该设备(而将其视为通用开发机器(。Miniconda被剥离了足够,手臂支撑很少,我发现即使在Minconda环境中,我也需要为很多包裹提供很多包裹。唯一真正的好处是能够删除整个Miniconda树并开始干净,但是如果我要这样做,我可能会启动整个操作系统。

从这里开始安装jupyter:http://jupyter.org/install

您可以在PI上打开jupyter的HTTP端口,并通过本地网络访问它,也可以使用以下方式在SSH上进行隧道。

ssh -L 8001:localhost:8888 raspberrypi.local

我喜欢的方式是安装JupyterHub:https://github.com/jupyterhub/jupyterhub

这主要是直接的,一个问题是您要确保与SSL的连接,这可能意味着具有以下内容的自签名证书:

openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout jupyterhub.key -out

问题在于,野生动物园会窒息自签名的证书。您需要在钥匙扣中信任它:https://support.apple.com/kb/ph25443?locale= en_us& viewlocale = en_us

您可以通过单击"访问站点"暂时绕过问题,但是长期解决方案是单击其他选项,查看证书,将其拖到桌面上,在钥匙串中打开,然后信任它。p>您需要通过JupyterHub配置,但是两个对我来说并不明显的选项,但有用这些:

c.JupyterHub.cookie_secret_file = '/srv/jupyterhub/jupyterhub_cookie_secret'
c.JupyterHub.db_url = '/srv/jupyterhub/jupyterhub.sqlite'

可以随心所欲地设置这些路径,但是它们可以使您免于在您启动jupyterhub的任何目录中创建文件。

将jupyterhub设置在启动时也可能很有用:

#setup jupyterhub to launch at boot
create /etc/systemd/system/jupyterhub.service:
[Unit]
Description=Jupyterhub
After=syslog.target network.target
[Service]
User=root
Environment="PATH=/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ExecStart=/opt/miniconda3/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py
[Install]
WantedBy=multi-user.target

sudo systemctl enable jupyterhub

最后,Jupyterlab也有效:http://jupyterlab.readthedocs.io/en/stable/getting_started/installation.htmlhttp://jupyterlab.readthedocs.io/en/stable/user/jupyterhub.html

设置此设置后,您可以像在本地计算机上一样在Jupyter中开发。它还使您可以从浏览器内部访问终端。

如果您四处挖掘,也有设置PI的方法,因此它显示在Finder中的文件共享中,并允许您从本机MacOS屏幕共享中进行VNC。

您没有具体要求,但是如果您在做相机工作,那么值得安装OpenCV。这应该使您大部分时间。它假设Miniconda已安装在/opt/miniconda3中,并包括为Python3构建OPENCV的标志:

#install opencv
#https://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html
#note: some optional packages not installed
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev
sudo apt-get install cmake-curses-gui
sudo apt-get install libopenexr-dev

#from the OpenCV source directory
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release 
-D CMAKE_INSTALL_PREFIX=/usr/local 
-D BUILD_opencv_python3=yes 
-D PYTHON3_INCLUDE_DIR=/opt/miniconda3/include/python3.4m 
-D PYTHON3_LIBRARY=/opt/miniconda3/lib/libpython3.4m.so 
-D PYTHON3_PACKAGES_PATH=/opt/miniconda3/lib/python3.4/site-packages 
..

make -j4
#this might take more than one attempt, for some reason it crashed the first time through, but succeeded the second
sudo make install

最新更新