embeded/raspberry pi2015. 9. 15. 12:43

bcm2835-v4l2 모듈만 불러주면 해결

(테스트 라즈비안 2015.5.5일자 클린상태)

---

uv4l2를 설치해서 되는건진 테스트 필요 (sd 밀고 다시 설정하고.. 아으 ㅋㅋㅋㅋ)

$ sudo apt-get install uv4l uv4l-raspicam uv4l-raspicam-extras uv4l-server uv4l-uvc uv4l-xscreen uv4l-mjpegstream 

---


Camera Enable로 설정 후 재부팅

$ sudo raspi-config


$ sudo modprobe bcm2835-v4l2

$ lsmod | grep v4l

bcm2835_v4l2           37265  0

videobuf2_vmalloc       5397  1 bcm2835_v4l2

videobuf2_core         34020  1 bcm2835_v4l2

v4l2_common             3766  2 bcm2835_v4l2,videobuf2_core

videodev              124141  3 bcm2835_v4l2,v4l2_common,videobuf2_core


$ dmesg

[ 6468.552996] media: Linux media interface: v0.10

[ 6468.574380] Linux video capture interface: v2.00

[ 6468.610013] bcm2835-v4l2: scene mode selected 0, was 0

[ 6468.610559] bcm2835-v4l2: V4L2 device registered as video0 - stills mode > 1280x720

[ 6468.615652] bcm2835-v4l2: Broadcom 2835 MMAL video capture ver 0.0.2 loaded.


$ ls -al /dev/video0

crw-rw-rwT+ 1 root video 81, 0  9월 15 12:37 /dev/video0 


[링크 : http://www.ics.com/blog/raspberry-pi-camera-module]


만약 start_x를 추가하지 않아 카메라가 활성화 되지 않으면

Operation not permitted 라는 에러 메시지가 발생된다.

$ lsmod

Module                  Size  Used by

cuse                    5065  0

fuse                   81710  2 cuse

snd_bcm2835            19769  0

snd_pcm                74825  1 snd_bcm2835

snd_seq                53561  0

snd_seq_device          3650  1 snd_seq

snd_timer              18157  2 snd_pcm,snd_seq

snd                    52116  5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device

uio_pdrv_genirq         2966  0

uio                     8235  1 uio_pdrv_genirq


$ sudo modprobe bcm2835-v4l2

ERROR: could not insert 'bcm2835_v4l2': Operation not permitted


$ dmesg

[   33.911831] media: Linux media interface: v0.10

[   33.932822] Linux video capture interface: v2.00

[   33.957085] : bcm2835-v4l2: error -1 while loading driver 


Camera

start_x Enable the camera module.

 start_x=1


disable_camera_led Turn off the red camera LED when recording video or taking a still picture

 disable_camera_led=1


gpu_mem minimum GPU memory for camera use

 gpu_mem=128

[링크 : http://elinux.org/RPiconfig#Camera] 


움직임 감지시 이미지로 저장하는 부분

output_normal을 off로 하면 "target_dir" 에 저장을 하지 않음

############################################################

# Image File Output

############################################################


# Output 'normal' pictures when motion is detected (default: on)

# Valid values: on, off, first, best, center

# When set to 'first', only the first picture of an event is saved.

# Picture with most motion of an event is saved when set to 'best'.

# Picture with motion nearest center of picture is saved when set to 'center'.

# Can be used as preview shot for the corresponding movie.

output_normal off


# Output pictures with only the pixels moving object (ghost images) (default: off)

output_motion off


# The quality (in percent) to be used by the jpeg compression (default: 75)

quality 75


# Output ppm images instead of jpeg (default: off)

ppm off


움직임 감지시 동영상 저장 부분. swf가 기본값이며 ffmpeg_cap_new를 off로 해주면 저장되지 않았다.

(기본값이 off라면서 on이 되어 있냐 -_-)

############################################################

# FFMPEG related options

# Film (mpeg) file output, and deinterlacing of the video input

# The options movie_filename and timelapse_filename are also used

# by the ffmpeg feature

############################################################


# Use ffmpeg to encode mpeg movies in realtime (default: off)

ffmpeg_cap_new off


# Use ffmpeg to make movies with only the pixels moving

# object (ghost images) (default: off)

ffmpeg_cap_motion off


# Use ffmpeg to encode a timelapse movie

# Default value 0 = off - else save frame every Nth second

ffmpeg_timelapse 0


# The file rollover mode of the timelapse video

# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual

ffmpeg_timelapse_mode daily


# Bitrate to be used by the ffmpeg encoder (default: 400000)

# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled)

ffmpeg_bps 500000


# Enables and defines variable bitrate for the ffmpeg encoder.

# ffmpeg_bps is ignored if variable bitrate is enabled.

# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps,

# or the range 2 - 31 where 2 means best quality and 31 is worst.

ffmpeg_variable_bitrate 0


# Codec to used by ffmpeg for the video compression.

# Timelapse mpegs are always made in mpeg1 format independent from this option.

# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4.

# mpeg1 - gives you files with extension .mpg

# mpeg4 or msmpeg4 - gives you files with extension .avi

# msmpeg4 is recommended for use with Windows Media Player because

# it requires no installation of codec on the Windows client.

# swf - gives you a flash film with extension .swf

# flv - gives you a flash video with extension .flv

# ffv1 - FF video codec 1 for Lossless Encoding ( experimental )

# mov - QuickTime ( testing )

ffmpeg_video_codec swf


# Use ffmpeg to deinterlace video. Necessary if you use an analog camera

# and see horizontal combing on moving objects in video or pictures.

# (default: off)

ffmpeg_deinterlace off 


motion.conf

I ended up commented these out when i was testing but not totally sure if it helped.

It's prolly ok to leave motion.conf pretty much as it was but this works fine for me and that's how it's gonna stay now it's fully working.


;netcam_url value

;target_dir value

;webcam_port 8081

;videodevice /dev/video0

[링크 : http://ubuntuforums.org/showthread.php?t=1897786] 


화면이 안떠서 디버깅을 해보니 예제로 된 /etc/motion/motion.conf 에서

thread의 경로가 잘못 잡힌 것을 발견

$ sudo motion[0] Processing thread 0 - config file /etc/motion/motion.conf

[0] Thread config file /usr/local/etc/thread1.conf not found: No such file or directory

[0] Thread config file /usr/local/etc/thread2.conf not found: No such file or directory

[0] Motion 3.2.12 Started

[0] Motion going to daemon mode 


이렇게 하니.. 8081 8082 포트로 접속이 된다.

$ sudo vi /etc/motion/motion.conf
# thread config files.

thread /etc/motion/thread1.conf

thread /etc/motion/thread2.conf

; thread /usr/local/etc/thread3.conf

; thread /usr/local/etc/thread4.conf 



8080 에서는 작동중인 쓰레드가

8081 에는 cam1


8082에는 cam2



15 프레임 캡쳐 / 15 프레임 스트리밍 해둔건데 cpu가 1개 코어 100%를 먹네.. ㄷㄷㄷ



+

그나저나 아이패드에서는 영상이 가로/세로 바꾸거나 스크롤을 하는 동안에만 잠시 보인다..

머가 문제라서 리프레시가 자동으로 안될까?


+

갤럭시 S2 에서는 다운로드..


+

IE 에서도 다운로드

크롬외에는 쓸모가 없나 -ㅁ-?

아니면.. HTTP 스트리밍이 되는.. vlc?


Posted by 구차니