728x90

Raspberry Pi 4

Raspberry Pi 4 전원

Raspberry Pi 4에서 사용하는 전원은 5.1v 3A로 PC의 USB의 전원으로 연결하면 정상적으로 운영이 되지 않는 것 같습니다.

OS설치 (NOOBS 설치)

아직 테스트가 더 필요하지만, 현재 배포 되는 Raspbian (2019-06-20 배포판) 의 이미지(img파일)파일 설치는 아직 설치가 안되는 것 같고, NOOBS (2019-06-24 배포판)으로 설치해보았습니다.

Micro HDMI

Micro HDMI 어댑터를 구입해서 기존에 사용하던 HDMI케이블에 연결해서 사용하면 문제 없이 사용이 가능했습니다.

한글폰트 설치

$ sudo apt install fonts-unfonts-core

RDP (원격 데스크톱) 설치

$ sudo apt-get install xrdp
$ sudo apt-get install xorgxrdp

YouTube 시청

728x90
728x90

출처

Raspberry Pi 4 개봉기

주문한지 3일만에 받았습니다.
외관상 크기는 이전과 동일하지만 기존 pi3 케이스는 사용 할 수가 없어서 같이 주문한 케이스와 방열판을 붙여 보았습니다.

Raspberry Pi 4 스펙

  • 1.5GHz 64 비트 쿼드 코어 ARM Cortex-A72 CPU (ARM v8, BCM2837)
  • 1GB, 2GB 또는 4GB RAM (LPDDR4)
  • 온보드 무선 LAN - 듀얼 밴드 802.11 b / g / n / ac
  • 온보드 Bluetooth 5.0, 저에너지 (BLE)
  • 2x USB 3.0 포트, 2x USB 2.0 포트
  • 기가비트 이더넷
  • Power-over-Ethernet (추가 Raspberry Pi PoE HAT가 필요함)
  • 40 핀 GPIO 헤더
  • 2 × 마이크로 HDMI 포트 (최대 4Kp60 지원)
  • H.265 (4Kp60 디코드)
  • H.264 (1080p60 디코드, 1080p30 인 코드)
  • OpenGL ES, 3.0 그래픽
  • DSI 디스플레이 포트, CSI 카메라 포트
  • 결합 된 3.5mm 아날로그 오디오 및 컴포지트 비디오 잭
  • 마이크로 SD 카드 슬롯
  • USB-C 전원

728x90
728x90

출처

불필요한 패키지 제거

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

라즈비안(Raspberry pi OS)의 업데이트와 업그레이드

$ sudo apt-get update && sudo apt-get upgrade

OpenCV 4.1 관련 패키지 설치

OpenCV 빌드 관련 도구 설치

$ sudo apt-get install build-essential cmake unzip pkg-config

OpenCV 관련 라이브러리 설치

$ sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev

GTK 관련 라이브러리 설치

$ sudo apt-get install libgtk-3-dev

OpenCV 수치 최적화가 된 패키지 설치

$ sudo apt-get install libatlas-base-dev gfortran

Python3 설치

$ sudo apt-get install python3-dev

OpenCV 4.1 다운로드

OpenCV 4.1.0 소스 다운로드

$ cd ~
$ wget -O opencv.zip https://github.com/opencv/opencv/archive/4.1.0.zip
$ wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.1.0.zip

압축풀기

$ unzip opencv.zip
$ unzip opencv_contrib.zip

디렉토리명 변경

$ mv opencv-4.1.0 opencv
$ mv opencv_contrib-4.1.0 opencv_contrib

OpenCV 4.1 용 Python 3 가상 환경 구성

pip 설치

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python3 get-pip.py
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
     |████████████████████████████████| 1.4MB 1.1MB/s 
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-19.1.1

virtualenv, virtualenvwrapper 설치

$ sudo pip install virtualenv virtualenvwrapper
$ sudo rm -rf ~/get-pip.py ~/.cache/pip

python3, virtualenv 환경설정

$ echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.profile
$ echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.profile
$ echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.profile
$ echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.profile
$ source ~/.profile

가상환경을 만들고, OpenCV 4.1 관련 패키지 추가

$ mkvirtualenv cv -p python3
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/pi/.virtualenvs/cv/bin/python3
Also creating executable in /home/pi/.virtualenvs/cv/bin/python
Installing setuptools, pip, wheel...
done.
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/cv/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/cv/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/cv/bin/preactivate
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/cv/bin/postactivate
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/cv/bin/get_env_details

workon 명령을 사용하여 cv 환경에 있는지 확인

pi@raspberrypi:~$ workon cv
(cv) pi@raspberrypi:~$ 

numpy 파이썬 패키지 설치(OpenCV관련 수학 함수 모음)

pi@raspberrypi:~$ workon cv
(cv) pi@raspberrypi:~$ pip install numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting numpy
  Using cached https://www.piwheels.org/simple/numpy/numpy-1.16.4-cp37-cp37m-linux_armv7l.whl
Installing collected packages: numpy
Successfully installed numpy-1.16.4
(cv) pi@raspberrypi:~$ python
Python 3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> quit()

OpenCV 컴파일

CMake 실행

$ cd ~/opencv
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
     -D CMAKE_INSTALL_PREFIX=/usr/local \
     -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
     -D ENABLE_NEON=ON \
     -D ENABLE_VFPV3=ON \
     -D BUILD_TESTS=OFF \
     -D OPENCV_ENABLE_NONFREE=ON \
     -D INSTALL_PYTHON_EXAMPLES=OFF \
     -D OPENCV_GENERATE_PKGCONFIG=YES \
     -D BUILD_EXAMPLES=OFF ..
 
... 생략 ...
 
-- General configuration for OpenCV 4.1.0 =====================================
--   Version control:               unknown
-- 
--   Extra modules:
--     Location (extra):            /home/pi/opencv_contrib/modules
--     Version control (extra):     unknown
-- 
--   Platform:
--     Timestamp:                   2019-07-01T15:38:09Z
--     Host:                        Linux 4.19.50-v7+ armv7l
--     CMake:                       3.13.4
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
-- 
--   CPU/HW features:
--     Baseline:                    VFPV3 NEON
--       requested:                 DETECT
--       required:                  VFPV3 NEON
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++  (ver 8.3.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--gc-sections  
--     Linker flags (Debug):        -Wl,--gc-sections  
--     ccache:                      NO
--     Precompiled headers:         YES
--     Extra dependencies:          dl m pthread rt
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv hdf java js matlab ovis python2 sfm viz
--     Applications:                perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         YES
-- 
--   GUI: 
--     GTK+:                        YES (ver 3.24.5)
--       GThread :                  YES (ver 2.58.3)
--       GtkGlExt:                  NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver 62)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.6.36)
--     TIFF:                        /usr/lib/arm-linux-gnueabihf/libtiff.so (ver 42 / 4.0.10)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES
--       avcodec:                   YES (58.35.100)
--       avformat:                  YES (58.20.100)
--       avutil:                    YES (56.22.100)
--       swscale:                   YES (5.3.100)
--       avresample:                NO
--     GStreamer:                   NO
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (built-in)
-- 
--   Other third-party libraries:
--     Lapack:                      NO
--     Eigen:                       NO
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--     Protobuf:                    build (3.5.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/pi/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 3:
--     Interpreter:                 /home/pi/.virtualenvs/cv/bin/python3 (ver 3.7.3)
--     Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython3.7m.so (ver 3.7.3)
--     numpy:                       /home/pi/.virtualenvs/cv/lib/python3.7/site-packages/numpy/core/include (ver 1.16.4)
--     install path:                lib/python3.7/site-packages/cv2/python-3.7
-- 
--   Python (for build):            /home/pi/.virtualenvs/cv/bin/python3
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/opencv/build

SWAP 사이즈 늘리기

dphys-swapfile 편집

$ sudo vi /etc/dphys-swapfile

CONF_SWAPSIZE 값을 2024 (2GB)로 설정

# set size to absolute value, leaving empty (default) then uses computed value
#   you most likely don't want this, unless you have an special disk situation
# CONF_SWAPSIZE=100
CONF_SWAPSIZE=2048

dphys-swapfile 재실행

$ sudo /etc/init.d/dphys-swapfile stop
Stopping dphys-swapfile (via systemctl): dphys-swapfile.service.
$ sudo /etc/init.d/dphys-swapfile start
Starting dphys-swapfile (via systemctl): dphys-swapfile.service

OpenCV 컴파일

$ make -j4

OpenCV 설치

$ sudo make install
$ sudo ldconfig

SWAP 이전 사이즈 돌려놓기

1. CONF_SWAPSIZE를 100MB로 재설정
2. 스왑 서비스를 재시작

OpenCV 4를 Python 3 가상 환경에 복사(소프트링크)

$ cd ~/.virtualenvs/cv/lib/python3.7/site-packages/
$ ln -s /usr/local/lib/python3.7/site-packages/cv2/python-3.7/cv2.cpython-37m-arm-linux-gnueabihf.so cv2.so
$ cd ~

OpenCV 설치 확인

파이썬

$ workon cv
$ python
Python 3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.1.0'
>>> exit()

C++

#include "opencv2/opencv.hpp"
 
using namespace cv;
using namespace std;
 
int main( int argc, char** argv )
{
  cout << "OpenCV version : " << CV_VERSION << endl;
  cout << "Major version : " << CV_MAJOR_VERSION << endl;
  cout << "Minor version : " << CV_MINOR_VERSION << endl;
  cout << "Subminor version : " << CV_SUBMINOR_VERSION << endl;
}

$ g++ opencv_check_version.cpp -o opencv_check_version `pkg-config --cflags --libs opencv4`
$ ./opencv_check_version 
OpenCV version : 4.1.0
Major version : 4
Minor version : 1
Subminor version : 0
728x90
728x90

출처

언어 설정

메뉴 [기본 설정] > [Raspberry Pi Configuration] 선택

탭 [Localisation] 선택

버튼 [Set Locale...] 선택하고, 팝업 창[Locale] 에서 Language, Character Set 설정

버튼 [Set Timezone...] 선택하고, 팝업 창[Timezone] 에서 Area, Location 설정

버튼 [Set Keyboard...] 선택하고, 팝업 창[Keyboard] 에서 Model, Layout, Variant 설정

버튼 [Set WiFi Country Code...] 선택하고, 팝업 창[WiFi Country Code] 에서 Country 설정

한글 입력기(uim) 설치

$ sudo apt-get install uim uim-byeoru fonts-unfonts-core

uim로 입력기 설정

$ im-config -n uim

입력기 설정 확인

$ cat .xinputrc 
## im-config(8) generated on Sat, 20 Oct 2018 21:14:47 +0900
run_im uim
## im-config signature: 7e7926db202ba349880ee57ac6ef0013  -

입력기 설정 후 재부팅

$ sudo shutdown -r now

uim 입력기 설정

메뉴 [기본 설정] > [Raspberry Pi Configuration] 선택

[디폴트 입력기 지정]에서 ]디폴트 입력기]를 [벼루]로 설정

[Display behavior]에서 [Display]를 Never로 설정

[전체] 켜기, [전체] 끄기를 한영전환키 설정과 충돌이 생기지 않도록 비워두고 적용

벼루 키 설정 1

728x90
728x90

출처

spi 활성화

$ sudo raspi-config

개발도구 설치

$ sudo apt-get install python-dev python-setuptools

소스 다운로드 및 설치

$ wget -O InkypHAT.tar.gz https://github.com/pimoroni/inky-phat/archive/v0.1.0.tar.gz
$ tar xvf InkypHAT.tar.gz
$ cd inky-phat-0.1.0/library/
$ sudo python setup.py install

예제 실행

$ cd ~/inky-phat-0.1.0/examples/
$ python cal.py

728x90
728x90

출처

Driver 다운로드

$ wget http://kedei.net/raspberry/v6_1/LCD_show_v6_1_3.tar.gz

압축해제 후 설치(LCD에 화면 출력)

$ tar xvf LCD_show_v6_1_3.tar.gz
$ cd LCD_show_v6_1_3
$ sudo ./LCD35_v

다시 HDMI로 화면 출력

$ sudo ./LCD_hdmi
728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


출처

MJPG streamer 컴파일 관련 라이브러리 설치

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install cmake libjpeg8-dev imagemagick libv4l-dev

MJPG streamer 소스 다운로드, 컴파일, 설치

$ git clone https://github.com/jacksonliam/mjpg-streamer.git
$ cd mjpg-streamer/mjpg-streamer-experimental/
$ make
$ sudo make install

LD_LIBRARY_PATH 경로 추가

$ echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/mjpg-streamer" | sudo tee -a /etc/profile

MJPG Streamer 실행

출처 : MJPG Streamer configuration

$ mjpg_streamer -i "input_raspicam.so -x 640 -y 480 -fps 10 -rot 180 -ex night" --output "output_http.so -w /usr/local/share/mjpg-streamer/www --port 8080"

또는

$ mjpg_streamer -i "input_raspicam.so -x 320 -y 240 -quality 30 -fps 15 -rot 180 -ex night"

MJPG Streamer 실행 - 최적옵션

$ mjpg_streamer -i "input_uvc.so -r 320x240 -f 10 -y" --output "output_http.so -w /usr/local/share/mjpg-streamer/www --port 8080"

V4L2(Video4Linux2) 부팅시 활성화 시키기

$ sudo vi /etc/modules

아래 내용 추가

bcm2835-v4l2

서비스등록

$ sudo vi /etc/init.d/mjpg_streamer

mjpg_streamer 파일 내용

#!/bin/bash
# /etc/init.d/mjpg_streamer.sh
# v0.2 phillips321.co.uk
### BEGIN INIT INFO
# Provides:          mjpg_streamer.sh
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mjpg_streamer for webcam
# Description:       Streams /dev/video0 to http://IP/?action=stream
### END INIT INFO

#
export width=640
export height=480
export bitrate=10
export SHUTDOWN_WAIT=2

if [ -n "$2" ]; then
  width=$2 
fi

if [ -n "$3" ]; then
  height=$3
fi

if [ -n "$4" ]; then
  bitrate=$4
fi

export LD_MJPG_STREAMER=/usr/local/lib/mjpg-streamer

f_message(){
        echo "[+] $1"
}

mjpg_streamer_pid() {
  echo `ps aux | grep mjpg-streamer | grep -v grep | awk '{ print $2 }'`
}

start() {
  pid=$(mjpg_streamer_pid)
  if [ -n "$pid" ] 
  then
    echo "mjpg_streamer is already running (pid: $pid)"
  else
    # Start mjpg_streamer
		f_message "Starting mjpg_streamer"
		mjpg_streamer -b -i "$LD_MJPG_STREAMER/input_uvc.so -r "$width"x"$height" -f $bitrate -y" -o "$LD_MJPG_STREAMER/output_http.so -p 8080 -w /usr/local/share/mjpg-streamer/www"
		sleep 2
		f_message "mjpg_streamer started"
  fi

  return 0
}

stop() {
  pid=$(mjpg_streamer_pid)
  if [ -n "$pid" ]
  then
    f_message "Stopping mjpg_streamer..."
    kill -9 $pid

    let kwait=$SHUTDOWN_WAIT
    let count=0;
    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
    do
      echo -n -e "\nwaiting for processes to exit";
      sleep 1
      let count=$count+1;
    done

    if [ $count -gt $kwait ]; then
      echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\n"
      kill -9 $pid
    fi
  else
    echo "mjpg_streamer is not running"
  fi
 
  return 0
}

# Carry out specific functions when asked to by the system
case "$1" in
        start)
                 start
                 ;;
        stop)
                 stop
                 ;;
        restart)
                 stop
                 sleep 2
                 start
                 ;;
        resolution)
                resolution=`ps axu | grep mjpg-streamer | grep -v grep | awk '{ print $16 }'`
                if [ -n "$resolution" ];
                then
                        echo "${resolution}"
                else
                        echo "0x0"
                fi
                ;;
        status)
                pid=`ps -A | grep mjpg_streamer | grep -v "grep" | grep -v mjpg_streamer. | awk '{print $1}' | head -n 1`
                if [ -n "$pid" ];
                then
                        f_message "mjpg_streamer is running with pid ${pid}"
                        f_message "mjpg_streamer was started with the following command line"
                        cat /proc/${pid}/cmdline ; echo ""
                else
                        f_message "Could not find mjpg_streamer running"
                fi
                ;;
        *)
                f_message "Usage: $0 {start|stop|status|restart}"
                exit 1
                ;;
esac
exit 0

등록

$ sudo chmod u+x /etc/init.d/mjpg_streamer
$ sudo update-rc.d mjpg_streamer defaults

서비스 실행 및 실행 확인

$ sudo service mjpg_streamer start
$ sudo service mjpg_streamer status
[0m mjpg_streamer.service - LSB: mjpg_streamer for webcam
   Loaded: loaded (/etc/init.d/mjpg_streamer)
   Active: active (running) since Sat 2016-05-21 15:18:17 UTC; 8s ago
  Process: 1373 ExecStop=/etc/init.d/mjpg_streamer stop (code=killed, signal=TERM)
  Process: 1403 ExecStart=/etc/init.d/mjpg_streamer start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mjpg_streamer.service
           붴1407 mjpg_streamer -b -i /usr/local/lib/mjpg-streamer/input_uvc.so -r 320x240 -f 10 -y -o /usr/local/lib/mjpg-s...
 
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: TV-Norm...........: DEFAULT
May 21 15:18:15 raspberrypi mjpg_streamer[1403]: enabling daemon modeforked to background (1407)
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: www-folder-path...: /usr/local/share/mjpg-streamer/www/
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: HTTP TCP port.....: 8080
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: username:password.: disabled
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: commands..........: enabled
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: starting input plugin /usr/local/lib/mjpg-stream...vc.so
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: starting output plugin: /usr/local/lib/mjpg-stre...: 00)
May 21 15:18:17 raspberrypi mjpg_streamer[1403]: [+] mjpg_streamer started
May 21 15:18:17 raspberrypi systemd[1]: Started LSB: mjpg_streamer for webcam.
Hint: Some lines were ellipsized, use -l to show in full.

확인

html 코드

출처 : mjpegcanvasjs / Tutorials / CreatingASingleStreamCanvas

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="eventemitter2.min.js"></script>
<script type="text/javascript" src="mjpegcanvas.min.js"></script>

<script type="text/javascript" type="text/javascript">
  /**
   * Setup all visualization elements when the page is loaded. 
   */
  function init() {
    // Create the main viewer.
     var viewer = new MJPEGCANVAS.Viewer({
      divID : 'mjpeg',
     host : '192.168.0.14',
     port : '8080',
      width : 640,
       height : 480,
      topic : '/?action=stream'
     });
 }
</script>
</head>
 
<body onload="init()">
<h1>Simple MJPEG Canvas Example</h1>
<div id="mjpeg"></div>
</body>
</html>



라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


출처

배선

소스 (L298NMain.java)

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.RaspiPin;

public class L298NMain {

        private static GpioController gpio = null;

        static GpioPinDigitalOutput pin1;
        static GpioPinDigitalOutput pin2;

        public static void forword() {
                System.out.println("GPIO Forward");
                pin1.high();
                pin2.low();
        }

        public static void backword() {
                System.out.println("GPIO Backward");
                pin1.low();
                pin2.high();
        }

        public static void stopFB() {
                System.out.println("GPIO Stop Back Wheel");
                pin1.low();
                pin2.low();
                /*
                try {
                        Thread.sleep(700);
                } catch (Exception e) {
                        e.printStackTrace();
                }
                */
        }

        public static void main(String[] args) throws Exception {
                gpio = GpioFactory.getInstance();
                //gpio.setMode(PinMode.DIGITAL_OUTPUT);
                pin1 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_08);
                pin2 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_09);

                forword();
                Thread.sleep(2000);
                backword();
                Thread.sleep(2000);

                stopFB();

                gpio.shutdown();
        }
}

컴파일

$ javac -cp .:lib/pi4j-core.jar L298NMain.java

실행

$ java -cp .:lib/pi4j-core.jar L298NMain

실행 영상



라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90

+ Recent posts