Raspberry Development Environment

Overview

Ref: http://www.waveshare.net/study/portal.php?mod=view&aid=594

Install System

  1. Download raspberry 'img' from https://www.raspberrypi.org/downloads/raspbian/
  2. Format an SD card with NTFS or Fat format.
  3. Download Etcher and then use Etcher to write 'img' to SD card.

SSH

pi@raspberrypi:~ $ sudo /etc/init.d/ssh start

raspi-config

pi@raspberrypi:~ $ sudo raspi-config

expand your filesystem:

Change keyboard layout to US from UK:


 ->Generic 104-key PC 
             ->English(US) 
               ->The default for the keyboard layout 
                 ->No compose key
                   ->ctrl_alt_backspace Yes

or 

 sudo vim /etc/default/keyboard
# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

Open VNC, SSH, Camera from "interface options"



Select "update" to update package and then reboot the system after config completed

Clean Unused Software to Reclaim Space

From there, delete both Wolfram Engine and LibreOffice to reclaim ~1GB of space on your Raspberry Pi:

sudo apt-get purge wolfram-engine
sudo apt-get purge libreoffice*
sudo apt-get clean
sudo apt-get autoremove

Install PiCamera

sudo apt-get install python-pip
sudo apt-get install python-dev
sudo pip install picamera

Install dependencies

Save these commands to a bash script file to run automatically.

sudo apt-get update && sudo apt-get upgrade
sudo apt-get update --fix-missing
sudo apt-get -y install build-essential cmake pkg-config
sudo apt-get -y install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get -y install libxvidcore-dev libx264-dev
sudo apt-get -y install libgtk2.0-dev libgtk-3-dev
sudo apt-get -y install libcanberra-gtk*
sudo apt-get -y  install libatlas-base-dev gfortran
sudo apt-get -y install python2.7-dev python3-dev

Putty & XMING

Install Putty: https://www.putty.org/

Install Xming: https://sourceforge.net/projects/xming/

Start File Folder from Putty

pi@raspberrypi:~ $ pcmanfm &
[1] 1145
pi@raspberrypi:~ $ ** Message: x-terminal-emulator has very limited support, consider choose another terminal
^C
[1]+  Done                    pcmanfm

Open Web Browser

pi@raspberrypi:~ $ epiphany-browser &
[2] 1182

Capture Image

pi@raspberrypi:~ $ sudo apt-get install fswebcam

Capture an image using "fswebcam" and then save to image.jpg

pi@raspberrypi:~ $ fswebcam -r 640x480 --no-banner image.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Disabling banner.
Writing JPEG image to 'image.jpg'.
pi@raspberrypi:~ $ pcmanfm &
[3] 17113
[2]   Done                    epiphany-browser
pi@raspberrypi:~ $ ** Message: x-terminal-emulator has very limited support, consider choose another terminal
netsurf-gtk 'file:///home/pi/image.jpg'

Check "image.jpg"

Video Record

pi@raspberrypi:~ $ sudo apt-get install luvcview
pi@raspberrypi:~ $ luvcview -s 320x240
luvcview 0.2.6

SDL information:
  Video driver: x11
  A window manager is available
Device information:
  Device path:  /dev/video0
Stream settings:
  Frame format: MJPG
  Frame size:   320x240
  Frame rate:   30 fps

OpenCV

Check Whether OpenCV is installed

pi@raspberrypi:~ $ dpkg -l |less
pi@raspberrypi:~ $ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170124] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>>

If so, we know OpenCV (cv2) is not installed properly. (Skip this process if it works well.) 

pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get upgrade

This process maybe takes a long time. Please keep patient. Please try again when it finished. 

If still not work, try this:

pi@raspberrypi:~ $ sudo apt-get install python-numpy python-scipy python-matplotlib
pi@raspberrypi:~ $ sudo apt-get install libopencv-dev python-opencv
pi@raspberrypi:~ $ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170124] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'2.4.9.1'

Test OpenCV

OpenCV_test1.py

# OpenCV_test1.py

# this program opens the file in the same directory names "image.jpg" and displays the original image and a Canny edges of the original image

import cv2
import numpy as np
import os

###################################################################################################
def main():
    imgOriginal = cv2.imread("image.jpg")               # open image

    if imgOriginal is None:                             # if image was not read successfully
        print "error: image not read from file \n\n"        # print error message to std out
        os.system("pause")                                  # pause so user can see error message
        return                                              # and exit function (which exits program)
    # end if

    imgGrayscale = cv2.cvtColor(imgOriginal, cv2.COLOR_BGR2GRAY)        # convert to grayscale

    imgBlurred = cv2.GaussianBlur(imgGrayscale, (5, 5), 0)              # blur

    imgCanny = cv2.Canny(imgBlurred, 100, 200)                          # get Canny edges

    cv2.namedWindow("imgOriginal", cv2.WINDOW_AUTOSIZE)        # create windows, use WINDOW_AUTOSIZE for a fixed window size
    cv2.namedWindow("imgCanny", cv2.WINDOW_AUTOSIZE)           # or use WINDOW_NORMAL to allow window resizing

    cv2.imshow("imgOriginal", imgOriginal)         # show windows
    cv2.imshow("imgCanny", imgCanny)

    cv2.waitKey()                               # hold windows open until user presses a key

    cv2.destroyAllWindows()                     # remove windows from memory

    return

###################################################################################################
if __name__ == "__main__":
    main()
pi@raspberrypi:~ $ vim OpenCV_test1.py
pi@raspberrypi:~ $ python OpenCV_test1.py


Study Resources

Compute Module IO Board Plus



Reference:

  1. Raspberry Pi - Change keyboard layout to US from default British layout, https://www.youtube.com/watch?v=L1F-TxTPyiM
  2.  MicrocontrollersAndMore, https://github.com/MicrocontrollersAndMore and youtube video
  3. Changing the Raspberry Pi Keyboard Layout from GUI, https://thepihut.com/blogs/raspberry-pi-tutorials/25556740-changing-the-raspberry-pi-keyboard-layout
  4. Compute Module IO Board Plus, http://www.waveshare.net/wiki/Compute_Module_IO_Board_Plus
  5. 微雪课堂, http://www.waveshare.net/study/portal.php?mod=view&aid=594
  6. MicrocontrollersAndMore, https://github.com/MicrocontrollersAndMore and youtube video
  7. 通过串口连接控制树莓派, http://www.cnblogs.com/ma6174/archive/2013/04/23/3038626.html
  8. 树莓派3硬件串口的使用及编程, http://etrd.org/2017/01/29/%E6%A0%91%E8%8E%93%E6%B4%BE3%E7%A1%AC%E4%BB%B6%E4%B8%B2%E5%8F%A3%E7%9A%84%E4%BD%BF%E7%94%A8%E5%8F%8A%E7%BC%96%E7%A8%8B/


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值