Raspberry Pi 라즈베리파이 - Anet A8 연결 3부:Camera setting (Connect Anet A8 and Pi3 with octoprint)
cd ~ sudo apt install subversion libjpeg62-turbo-dev imagemagick ffmpeg libv4l-dev cmake git clone https://github.com/jacksonliam/mjpg-streamer.git cd mjpg-streamer/mjpg-streamer-experimental export LD_LIBRARY_PATH=. make |
pi@rasp3-3d:~ $ sudo apt install subversion libjpeg62-turbo-dev imagemagick ffmpeg libv4l-dev cmake pi@rasp3-3d:~ $ git clone https://github.com/jacksonliam/mjpg-streamer.git 'mjpg-streamer'에 복제합니다... remote: Counting objects: 2741, done. remote: Total 2741 (delta 0), reused 0 (delta 0), pack-reused 2741 오브젝트를 받는 중: 100% (2741/2741), 3.45 MiB | 2.18 MiB/s, 완료. 델타를 알아내는 중: 100% (1727/1727), 완료. pi@rasp3-3d:~ $ cd mjpg-streamer/mjpg-streamer-experimental pi@rasp3-3d:~/mjpg-streamer/mjpg-streamer-experimental $ export LD_LIBRARY_PATH=. pi@rasp3-3d:~/mjpg-streamer/mjpg-streamer-experimental $ make [ -d _build ] || mkdir _build [ -f _build/Makefile ] || (cd _build && cmake -DCMAKE_BUILD_TYPE=Release ..) -- The C compiler identification is GNU 6.3.0 -- The CXX compiler identification is GNU 6.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMAKE_BUILD_TYPE = Release -- Looking for include file sys/inotify.h -- Looking for include file sys/inotify.h - found CMake Warning at plugins/input_opencv/CMakeLists.txt:4 (find_package): By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "OpenCV", but CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any of the following names:
OpenCVConfig.cmake opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set "OpenCV_DIR" to a directory containing one of the above files. If "OpenCV" provides a separate development package or SDK, be sure it has been installed.
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") -- Checking for module 'libgphoto2' -- No package 'libgphoto2' found -- Could NOT find GPHOTO2 (missing: GPHOTO2_LIBRARY GPHOTO2_INCLUDE_DIR) -- Looking for include file linux/videodev2.h -- Looking for include file linux/videodev2.h - found -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR) -- -- The following features have been enabled:
* PLUGIN_INPUT_FILE , File input plugin * PLUGIN_INPUT_HTTP , HTTP input proxy plugin * PLUGIN_INPUT_RASPICAM , Raspberry Pi input camera plugin * PLUGIN_INPUT_UVC , Video 4 Linux input plugin * PLUGIN_OUTPUT_FILE , File output plugin * PLUGIN_OUTPUT_HTTP , HTTP server output plugin * PLUGIN_OUTPUT_RTSP , RTSP output plugin * PLUGIN_OUTPUT_UDP , UDP output stream plugin
-- The following OPTIONAL packages have been found:
* Threads
-- The following features have been disabled:
* WXP_COMPAT , Enable compatibility with WebcamXP * PLUGIN_INPUT_OPENCV , OpenCV input plugin (unmet dependencies) * PLUGIN_INPUT_PTP2 , PTP2 input plugin (unmet dependencies) * ENABLE_HTTP_MANAGEMENT , Enable experimental HTTP management option * PLUGIN_OUTPUT_VIEWER , SDL output viewer plugin (unmet dependencies)
-- The following OPTIONAL packages have not been found:
* OpenCV * Gphoto2 * SDL
-- Configuring done -- Generating done -- Build files have been written to: /home/pi/mjpg-streamer/mjpg-streamer-experimental/_build make -C _build make[1]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 make[2]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target mjpg_streamer make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 4%] Building C object CMakeFiles/mjpg_streamer.dir/mjpg_streamer.c.o [ 8%] Building C object CMakeFiles/mjpg_streamer.dir/utils.c.o [ 12%] Linking C executable mjpg_streamer make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [ 12%] Built target mjpg_streamer make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target input_file make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 16%] Building C object plugins/input_file/CMakeFiles/input_file.dir/input_file.c.o [ 20%] Linking C shared library input_file.so make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [ 20%] Built target input_file make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target input_http make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 24%] Building C object plugins/input_http/CMakeFiles/input_http.dir/input_http.c.o [ 28%] Building C object plugins/input_http/CMakeFiles/input_http.dir/misc.c.o [ 32%] Building C object plugins/input_http/CMakeFiles/input_http.dir/mjpg-proxy.c.o [ 36%] Linking C shared library input_http.so make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [ 36%] Built target input_http make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target input_raspicam make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 40%] Building C object plugins/input_raspicam/CMakeFiles/input_raspicam.dir/input_raspicam.c.o In file included from /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c:51:0: /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/RaspiCamControl.c: In function ‘raspicamcontrol_set_saturation’: /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/RaspiCamControl.c:762:32: warning: implicit declaration of function ‘mmal_port_parameter_set_rational’ [-Wimplicit-function-declaration] ret = mmal_status_to_int(mmal_port_parameter_set_rational(camera->control, MMAL_PARAMETER_SATURATION, value)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/RaspiCamControl.c: In function ‘raspicamcontrol_set_ISO’: /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/RaspiCamControl.c:864:30: warning: implicit declaration of function ‘mmal_port_parameter_set_uint32’ [-Wimplicit-function-declaration] return mmal_status_to_int(mmal_port_parameter_set_uint32(camera->control, MMAL_PARAMETER_ISO, ISO)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/RaspiCamControl.c: In function ‘raspicamcontrol_set_video_stabilisation’: /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/RaspiCamControl.c:899:30: warning: implicit declaration of function ‘mmal_port_parameter_set_boolean’ [-Wimplicit-function-declaration] return mmal_status_to_int(mmal_port_parameter_set_boolean(camera->control, MMAL_PARAMETER_VIDEO_STABILISATION, vstabilisation)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/RaspiCamControl.c: In function ‘raspicamcontrol_set_exposure_compensation’: /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/RaspiCamControl.c:913:30: warning: implicit declaration of function ‘mmal_port_parameter_set_int32’ [-Wimplicit-function-declaration] return mmal_status_to_int(mmal_port_parameter_set_int32(camera->control, MMAL_PARAMETER_EXPOSURE_COMP , exp_comp)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c: In function ‘worker_thread’: /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c:885:10: warning: implicit declaration of function ‘mmal_port_pool_create’ [-Wimplicit-function-declaration] pool = mmal_port_pool_create(encoder_output, encoder_output->buffer_num, encoder_output->buffer_size); ^~~~~~~~~~~~~~~~~~~~~ /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c:885:8: warning: assignment makes pointer from integer without a cast -Wint-conversion] pool = mmal_port_pool_create(encoder_output, encoder_output->buffer_num, encoder_output->buffer_size); ^ /home/pi/mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c:1057:5: warning: implicit declaration of function ‘mmal_port_pool_destroy’ [-Wimplicit-function-declaration] mmal_port_pool_destroy(encoder->output[0], pool); ^~~~~~~~~~~~~~~~~~~~~~ [ 44%] Linking C shared library input_raspicam.so make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [ 44%] Built target input_raspicam make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target input_uvc make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 48%] Building C object plugins/input_uvc/CMakeFiles/input_uvc.dir/dynctrl.c.o [ 52%] Building C object plugins/input_uvc/CMakeFiles/input_uvc.dir/input_uvc.c.o [ 56%] Building C object plugins/input_uvc/CMakeFiles/input_uvc.dir/jpeg_utils.c.o [ 60%] Building C object plugins/input_uvc/CMakeFiles/input_uvc.dir/v4l2uvc.c.o [ 64%] Linking C shared library input_uvc.so make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [ 64%] Built target input_uvc make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target output_file make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 68%] Building C object plugins/output_file/CMakeFiles/output_file.dir/output_file.c.o [ 72%] Linking C shared library output_file.so make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [ 72%] Built target output_file make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target output_http make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 76%] Building C object plugins/output_http/CMakeFiles/output_http.dir/httpd.c.o [ 80%] Building C object plugins/output_http/CMakeFiles/output_http.dir/output_http.c.o [ 84%] Linking C shared library output_http.so make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [ 84%] Built target output_http make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target output_rtsp make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 88%] Building C object plugins/output_rtsp/CMakeFiles/output_rtsp.dir/output_rtsp.c.o [ 92%] Linking C shared library output_rtsp.so make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [ 92%] Built target output_rtsp make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 Scanning dependencies of target output_udp make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 들어감 [ 96%] Building C object plugins/output_udp/CMakeFiles/output_udp.dir/output_udp.c.o [100%] Linking C shared library output_udp.so make[3]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 [100%] Built target output_udp make[2]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 make[1]: 디렉터리 '/home/pi/mjpg-streamer/mjpg-streamer-experimental/_build' 나감 pi@rasp3-3d:~/mjpg-streamer/mjpg-streamer-experimental $ |
그리고 webcam을 서비스에 등록하기위한 스크립트 작성을 위해 따라함
pi@rasp3-3d:~ $ cd scripts -bash: cd: scripts: 그런 파일이나 디렉터리가 없습니다 pi@rasp3-3d:~ $ mkdir scripts pi@rasp3-3d:~ $ touch scripts/webcam pi@rasp3-3d:~ $ touch scripts/webcamDaemon pi@rasp3-3d:~ $ |
pi@rasp3-3d:~ $ vim scripts/webcam
#!/bin/bash # Start / stop streamer daemon
case "$1" in start) /home/pi/scripts/webcamDaemon >/dev/null 2>&1 & echo "$0: started" ;; stop) pkill -x webcamDaemon pkill -x mjpg_streamer echo "$0: stopped" ;; *) echo "Usage: $0 {start|stop}" >&2 ;; esac ~ ~ ~ ~ ~ ~ "webcam" 17L, 336C 17,4 모두 |
pi@rasp3-3d:~ $ vim scripts/webcamDaemon
MJPGSTREAMER_HOME=/home/pi/mjpg-streamer/mjpg-streamer-experimental MJPGSTREAMER_INPUT_USB="input_uvc.so" MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so"
# init configuration camera="auto" camera_usb_options="-r 640x480 -f 10" camera_raspi_options="-fps 10"
if [ -e "/boot/octopi.txt" ]; then source "/boot/octopi.txt" fi
# runs MJPG Streamer, using the provided input plugin + configuration function runMjpgStreamer { input=$1 pushd $MJPGSTREAMER_HOME echo Running ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" popd }
# starts up the RasPiCam function startRaspi { logger "Starting Raspberry Pi camera" runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options" }
# starts up the USB webcam function startUsb { logger "Starting USB webcam" runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options" }
# we need this to prevent the later calls to vcgencmd from blocking # I have no idea why, but that's how it is... vcgencmd version
# echo configuration echo camera: $camera echo usb options: $camera_usb_options echo raspi options: $camera_raspi_options
# keep mjpg streamer running if some camera is attached while true; do if [ -e "/dev/video0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then startUsb elif [ "`vcgencmd get_camera`" = "supported=1 detected=1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "raspi" ] ; }; then startRaspi fi
sleep 120 done 55,4 바닥 |
pi@rasp3-3d:~ $ chmod +x /home/pi/scripts/webcam pi@rasp3-3d:~ $ chmod +x /home/pi/scripts/webcamDaemon pi@rasp3-3d:~ $ |
pi@rasp3-3d:~ $ sudo vim /etc/rc.local
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing.
# Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi
/home/pi/scripts/webcam start
exit 0 ~ 20,28 모두 |
8080으로 접속을 해보니 MJPG-Steamer 페이지가 나옴
스냅샷 URL을 들어가면 사진이 딱!
근데 스트리밍은 안나옴.. 흠...
안나와서 별짓 다했는데 결론은 되는데 안뜬거...
http://pi_ip:8080/stream.html 접속해보면 Stream 나오는게 확인됨...
근데 127.0.0.1로는 Stream이 안되서 그냥 pi ip를 직접 넣어줌..
|
config.yaml 하단에 system을 추가해줌
pi@rasp3-3d:~ $ vim .octoprint/config.yaml
firstRun: false onlineCheck: enabled: true pluginBlacklist: enabled: true secretKey: 8D7W6SSbkpzHR6Bnpadj0LQagO8cJxN0 seenWizards: corewizard: 3 cura: null webcam: ffmpeg: /usr/bin/ffmpeg snapshot: http://127.0.0.1:8080/?action=snapshot stream: /webcam/?action=stream system: actions: - action: streamon command: /home/pi/scripts/webcam start confirm: false name: Start video stream - action: streamoff command: sudo /home/pi/scripts/webcam stop confirm: false name: Stop video stream ".octoprint/config.yaml" 54L, 1295C 54,6 바닥 |
카메라가 적외선이라 색상이 이상하게 보이지만... 한밤중에도 볼수 있다는 장점이...?
참고
댓글 영역