This passage summerize the website "Orange Pi Zero and Webcam for Octoprint", https://www.iot-experiments.com/orange-pi-zero-and-webcam-for-octoprint/, aimed to make my life easier.
Check the USB webcam present,
octoprint@orangepizero:~$ lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 046d:0826 Logitech, Inc. HD Webcam C525
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
...
09: USB 00.2: 0000 Unclassified device
[Created at usb.122]
Unique ID: O0wn.n7GFn22urBA
Parent ID: 2XnU.CpYmifTkid6
SysFS ID: /devices/platform/soc/1c1d000.usb/usb5/5-1/5-1:1.2
SysFS BusID: 5-1:1.2
Hardware Class: unknown
Model: "Logitech HD Webcam C525"
Hotplug: USB
Vendor: usb 0x046d "Logitech, Inc."
Device: usb 0x0826 "HD Webcam C525"
Revision: "0.10"
Serial ID: "CEB1D9D0"
Driver: "uvcvideo"
Driver Modules: "uvcvideo"
Device File: /dev/input/event0
Device Files: /dev/input/event0, /dev/input/by-id/usb-046d_HD_Webcam_C525_CEB1D9D0-event-if02, /dev/input/by-path/platform-1c1d000.usb-usb-0:1:1.2-event
Device Number: char 13:64
Speed: 480 Mbps
Module Alias: "usb:v046Dp0826d0010dcEFdsc02dp01ic0Eisc01ip00in02"
Driver Info #0:
Driver Status: uvcvideo is active
Driver Activation Cmd: "modprobe uvcvideo"
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #20 (Hub)
...
Find out capability of the cam,
octoprint@orangepizero:~$ sudo v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.042s (24.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.133s (7.500 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.042s (24.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.133s (7.500 fps)
Interval: Discrete 0.200s (5.000 fps)
...
Install MPEG streamer
octoprint@orangepizero:~$ apt-get install cmake libjpeg8-dev
octoprint@orangepizero:~$ git clone https://github.com/jacksonliam/mjpg-streamer.git
octoprint@orangepizero:~$ cd mjpg-streamer/mjpg-streamer-experimental
octoprint@orangepizero:~/OctoPrint/mjpg-streamer/mjpg-streamer-experimental$ make
octoprint@orangepizero:~/OctoPrint/mjpg-streamer/mjpg-streamer-experimental$ make install
Test MPEG streamer,
octoprint@orangepizero:~$ sudo mjpg_streamer -i "input_uvc.so -r 1280x720 -f 30" -o "output_http.so"
MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 1280 x 720
i: Frames Per Second.: 30
i: Format............: JPEG
i: TV-Norm...........: DEFAULT
UVCIOC_CTRL_ADD - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Mode: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Frequency: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Disable video processing: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Raw bits per pixel: Inappropriate ioctl for device (25)
o: www-folder-path......: disabled
o: HTTP TCP port........: 8080
o: HTTP Listen Address..: (null)
o: username:password....: disabled
o: commands.............: enabled
setting signal to stop
i: cleaning up resources allocated by input thread
force cancellation of threads and cleanup resources
o: cleaning up resources allocated by server thread #00
done
The stream is now available at,
Before configuring Octoprint, install ffmpeg:
octoprint@orangepizero:~$ sudo apt-get install ffmpeg
Octoprint start/stop scripts
octoprint@orangepizero:~$ mkdir scripts
octoprint@orangepizero:~$ cd scripts
Content of scripts/webcam.sh
#!/bin/bash
# Start / stop streamer daemon
case "$1" in
start)
/home/octoprint/scripts/webcamDaemon.sh >/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
Content of scripts/webcamDaemon.sh
#!/bin/bash
MJPGSTREAMER_HOME=/home/octoprint/mjpg-streamer/mjpg-streamer-experimental
MJPGSTREAMER_INPUT_USB="input_uvc.so"
# init configuration
camera="auto"
camera_usb_options="-r 640x480 -f 30"
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 USB webcam
function startUsb {
logger "Starting USB webcam"
runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options"
}
# echo configuration
echo camera: $camera
echo usb options: $camera_usb_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
logger "Not supported"
fi
sleep 120
done
Make scripts executable,
octoprint@orangepizero:~/scripts$ chmod a+x webcam.sh
octoprint@orangepizero:~/scripts$ chmod a+x webcamDaemon.sh
Edit Octoprint configuration
octoprint@orangepizero:~/scripts$ nano ~/.octoprint/config.yaml
Append to the end of config.yaml
system:
actions:
- action: streamon
command: /home/octoprint/scripts/webcam.sh start
confirm: false
name: Start video stream
- action: streamoff
command: /home/octoprint/scripts/webcam.sh stop
confirm: false
name: Stop video stream
Add user octoprint to video group
octoprint@orangepizero:~$ sudo usermod -aG video octoprint
Restart Octoprint
octoprint@orangepizero:~$ sudo service octoprint restart
Check the USB webcam present,
octoprint@orangepizero:~$ lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 046d:0826 Logitech, Inc. HD Webcam C525
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
To discover webcam information,
(octoprint@orangepizero:~$sudo apt-get install hwinfo)
octoprint@orangepizero:~$ hwinfo --usb
...
09: USB 00.2: 0000 Unclassified device
[Created at usb.122]
Unique ID: O0wn.n7GFn22urBA
Parent ID: 2XnU.CpYmifTkid6
SysFS ID: /devices/platform/soc/1c1d000.usb/usb5/5-1/5-1:1.2
SysFS BusID: 5-1:1.2
Hardware Class: unknown
Model: "Logitech HD Webcam C525"
Hotplug: USB
Vendor: usb 0x046d "Logitech, Inc."
Device: usb 0x0826 "HD Webcam C525"
Revision: "0.10"
Serial ID: "CEB1D9D0"
Driver: "uvcvideo"
Driver Modules: "uvcvideo"
Device File: /dev/input/event0
Device Files: /dev/input/event0, /dev/input/by-id/usb-046d_HD_Webcam_C525_CEB1D9D0-event-if02, /dev/input/by-path/platform-1c1d000.usb-usb-0:1:1.2-event
Device Number: char 13:64
Speed: 480 Mbps
Module Alias: "usb:v046Dp0826d0010dcEFdsc02dp01ic0Eisc01ip00in02"
Driver Info #0:
Driver Status: uvcvideo is active
Driver Activation Cmd: "modprobe uvcvideo"
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #20 (Hub)
...
Find out capability of the cam,
octoprint@orangepizero:~$ sudo apt-get install v4l-utils
octoprint@orangepizero:~$ sudo v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.042s (24.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.133s (7.500 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.042s (24.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.133s (7.500 fps)
Interval: Discrete 0.200s (5.000 fps)
...
Install MPEG streamer
octoprint@orangepizero:~$ apt-get install cmake libjpeg8-dev
octoprint@orangepizero:~$ git clone https://github.com/jacksonliam/mjpg-streamer.git
octoprint@orangepizero:~$ cd mjpg-streamer/mjpg-streamer-experimental
octoprint@orangepizero:~/OctoPrint/mjpg-streamer/mjpg-streamer-experimental$ make
octoprint@orangepizero:~/OctoPrint/mjpg-streamer/mjpg-streamer-experimental$ make install
Test MPEG streamer,
octoprint@orangepizero:~$ sudo mjpg_streamer -i "input_uvc.so -r 1280x720 -f 30" -o "output_http.so"
MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 1280 x 720
i: Frames Per Second.: 30
i: Format............: JPEG
i: TV-Norm...........: DEFAULT
UVCIOC_CTRL_ADD - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Mode: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Frequency: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Disable video processing: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Raw bits per pixel: Inappropriate ioctl for device (25)
o: www-folder-path......: disabled
o: HTTP TCP port........: 8080
o: HTTP Listen Address..: (null)
o: username:password....: disabled
o: commands.............: enabled
setting signal to stop
i: cleaning up resources allocated by input thread
force cancellation of threads and cleanup resources
o: cleaning up resources allocated by server thread #00
done
The stream is now available at,
http://192.168.68.112:8080/?action=stream
change 192.168.68.112 to the device IP address.
Octoprint setup
Before configuring Octoprint, install ffmpeg:
octoprint@orangepizero:~$ sudo apt-get install ffmpeg
Octoprint start/stop scripts
octoprint@orangepizero:~$ mkdir scripts
octoprint@orangepizero:~$ cd scripts
Content of scripts/webcam.sh
#!/bin/bash
# Start / stop streamer daemon
case "$1" in
start)
/home/octoprint/scripts/webcamDaemon.sh >/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
Content of scripts/webcamDaemon.sh
#!/bin/bash
MJPGSTREAMER_HOME=/home/octoprint/mjpg-streamer/mjpg-streamer-experimental
MJPGSTREAMER_INPUT_USB="input_uvc.so"
# init configuration
camera="auto"
camera_usb_options="-r 640x480 -f 30"
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 USB webcam
function startUsb {
logger "Starting USB webcam"
runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options"
}
# echo configuration
echo camera: $camera
echo usb options: $camera_usb_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
logger "Not supported"
fi
sleep 120
done
Make scripts executable,
octoprint@orangepizero:~/scripts$ chmod a+x webcam.sh
octoprint@orangepizero:~/scripts$ chmod a+x webcamDaemon.sh
Edit Octoprint configuration
octoprint@orangepizero:~/scripts$ nano ~/.octoprint/config.yaml
Append to the end of config.yaml
system:
actions:
- action: streamon
command: /home/octoprint/scripts/webcam.sh start
confirm: false
name: Start video stream
- action: streamoff
command: /home/octoprint/scripts/webcam.sh stop
confirm: false
name: Stop video stream
Add user octoprint to video group
octoprint@orangepizero:~$ sudo usermod -aG video octoprint
Restart Octoprint
octoprint@orangepizero:~$ sudo service octoprint restart
Thanks for Sharing!
ReplyDeleteReally a nice post.
Now You Can Easily Download Every Crack Software From Here*
Please Visit!
HWiNFO 7.12 Build 4580 crack
Ant Download Manager Pro crack
WinTools.net Premium 21.9 crack
UltimateDefrag crack
KeyShot Pro Crack