티스토리 뷰

728x90

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


출처

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

$ sudo vi /etc/modules

아래 내용 추가

bcm2835-v4l2

motion 설치

$ sudo apt-get install motion
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
The following additional packages will be installed:
  ffmpeg libavdevice57 libpq5 libsdl2-2.0-0
제안하는 패키지:
  ffmpeg-doc default-mysql-client postgresql-client
다음 새 패키지를 설치할 것입니다:
  ffmpeg libavdevice57 libpq5 libsdl2-2.0-0 motion
0개 업그레이드, 5개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
2,324 k바이트 아카이브를 받아야 합니다.
이 작업 후 4,718 k바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] 
받기:1 http://archive.raspberrypi.org/debian stretch/main armhf libavdevice57 armhf 7:3.2.10-1~deb9u1+rpt1 [109 kB]
받기:2 http://ftp.harukasan.org/raspbian/raspbian stretch/main armhf libsdl2-2.0-0 armhf 2.0.5+dfsg1-2 [314 kB]
받기:3 http://ftp.harukasan.org/raspbian/raspbian stretch/main armhf libpq5 armhf 9.6.7-0+deb9u1 [117 kB]                                     
받기:4 http://archive.raspberrypi.org/debian stretch/main armhf ffmpeg armhf 7:3.2.10-1~deb9u1+rpt1 [1,516 kB]                               
받기:5 http://ftp.harukasan.org/raspbian/raspbian stretch/main armhf motion armhf 4.0-1 [269 kB]                
내려받기 2,324 k바이트, 소요시간 6초 (371 k바이트/초)                                                                                          
패키지를 미리 설정하는 중입니다...
Selecting previously unselected package libsdl2-2.0-0:armhf.
(데이터베이스 읽는중 ...현재 115814개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../libsdl2-2.0-0_2.0.5+dfsg1-2_armhf.deb ...
Unpacking libsdl2-2.0-0:armhf (2.0.5+dfsg1-2) ...
Selecting previously unselected package libavdevice57:armhf.
Preparing to unpack .../libavdevice57_7%3a3.2.10-1~deb9u1+rpt1_armhf.deb ...
Unpacking libavdevice57:armhf (7:3.2.10-1~deb9u1+rpt1) ...
Selecting previously unselected package ffmpeg.
Preparing to unpack .../ffmpeg_7%3a3.2.10-1~deb9u1+rpt1_armhf.deb ...
Unpacking ffmpeg (7:3.2.10-1~deb9u1+rpt1) ...
Selecting previously unselected package libpq5:armhf.
Preparing to unpack .../libpq5_9.6.7-0+deb9u1_armhf.deb ...
Unpacking libpq5:armhf (9.6.7-0+deb9u1) ...
Selecting previously unselected package motion.
Preparing to unpack .../motion_4.0-1_armhf.deb ...
Unpacking motion (4.0-1) ...
libpq5:armhf (9.6.7-0+deb9u1) 설정하는 중입니다 ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
libsdl2-2.0-0:armhf (2.0.5+dfsg1-2) 설정하는 중입니다 ...
Processing triggers for systemd (232-25+deb9u2) ...
Processing triggers for man-db (2.7.6.1-2) ...
libavdevice57:armhf (7:3.2.10-1~deb9u1+rpt1) 설정하는 중입니다 ...
motion (4.0-1) 설정하는 중입니다 ...
Adding group `motion' (GID 115) ...
완료.
Warning: The home dir /var/lib/motion you specified already exists.
Adding system user `motion' (UID 111) ...
Adding new user `motion' (UID 111) with group `motion' ...
The home directory `/var/lib/motion' already exists.  Not copying from `/etc/skel'.
adduser: Warning: The home directory `/var/lib/motion' does not belong to the user you are currently creating.
Adding user `motion' to group `video' ...
사용자 motion을(를) video 그룹에 등록 중
완료.
ffmpeg (7:3.2.10-1~deb9u1+rpt1) 설정하는 중입니다 ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for systemd (232-25+deb9u2) ...

환경파일(motion.conf) 수정

$ sudo vi /etc/motion/motion.conf

환경파일 수정 내용

 11 daemon on
100 width 320
103 height 240
107 framerate 2
504 stream_localhost off
537 webcontrol_localhost off

실행

$ sudo motion -n
[0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[0:motion] [NTC] [ALL] motion_startup: Motion 4.0 Started
[0:motion] [NTC] [ALL] motion_startup: Logging to file (/var/log/motion/motion.log)

확인

서비스에 등록

/etc/default/motion 수정 내용

$ sudo vi /etc/default/motion

start_motion_daemon 값 no 에서 yes 로 수정

start_motion_daemon=yes

motion 서비스 등록

$ sudo systemctl enable motion
motion.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable motion

재부팅

$ sudo shutdown -r now

서비스 실행 확인

$ sudo sudo service motion status
● motion.service - LSB: Start Motion detection
   Loaded: loaded (/etc/init.d/motion; generated; vendor preset: enabled)
   Active: active (exited) since Sun 2018-07-08 23:19:36 KST; 1min 8s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 325 ExecStart=/etc/init.d/motion start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/motion.service
 
 7월 08 23:19:35 raspberrypi systemd[1]: Starting LSB: Start Motion detection...
 7월 08 23:19:36 raspberrypi motion[325]: Starting motion detection daemon: motion.
 7월 08 23:19:36 raspberrypi systemd[1]: Started LSB: Start Motion detection.

서비스 비활성화

$ sudo systemctl disable motion
motion.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable motion




개인 설정후 설정 파일로 실행 하기


환경파일(motion.conf) 수정 (motion 경로 생성, 환경파일 복사, vi)

$ mkdir ~/.motion
$ cp /etc/motion/motion.conf ~/.motion/motion.conf
$ vi ~/.motion/motion.conf

환경파일 수정 내용

 25 logfile /home/pi/Documents/motion/motion.log
100 width 640
103 height 480
145 mmalcam_name vc.ril.camera
253 event_gap 10
279 quality 80
273 output_pictures center
293 ffmpeg_output_movies off
392 locate_motion_mode preview
400 locate_motion_style redbox
415 text_changes on
450 target_dir /home/pi/Documents/motion
504 stream_localhost off
537 webcontrol_localhost off

motion 실행

$ motion -c ~/.motion/motion.conf
[0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /home/pi/.motion/motion.conf
[0:motion] [ALR] [ALL] conf_cmdparse: Unknown config option "mmalcam_name"
[0:motion] [NTC] [ALL] motion_startup: Motion 4.0 Started
[0:motion] [NTC] [ALL] motion_startup: Logging to file (/home/pi/Documents/motion/motion.log)



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

댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함