Articles Hierarchy

Articles Home » RPI » RPI with USB CAM + RPI_CAM +Screenshot

RPI with USB CAM + RPI_CAM +Screenshot

USB cam
RPI cam
screen cast
screen shot

USB cam
85 U 83 S 66 B 32 space 99 c 97 a 109 m
i had a unused OKER USB cam from a windows desktop ( used for skype.. )
the clip is broken, but the camera was fine, lens focus adjustment, ON/OFF switch for IR LEDs, PB for photo snapshot ( never had software in windows to use that )
now i try to use it on RPI3 using
pi@RPI3:~ $ lsusb
Bus 001 Device 005: ID 0c45:6340 Microdia

sudo apt-get install qv4l2

i install that software, found it under [menu][sound + video]
not touch any settings....
[header menu][capture][start capturing ]

play with the lens focus on the camera ( and take a win7 PC / VNC window / screen shot )

Col. John "Hannibal" Smith: I love it when a plan comes together.

when i try to save a snapshot photo from qv4l2
i was asked for a filename, WHAT EXTENSION???
try to dig about that YUYV frame thing.. and picture formats, even install gimp ( what can read lots of picture types)
well i give up on it.
sudo apt-get install fswebcam
fswebcam -d v4l2:/dev/video0 --list-inputs
fswebcam -d v4l2:/dev/video0 --list-controls
fswebcam -r 1280x960 --no-banner ~/Pictures/camtest.jpg

cd Pictures
TODAY=$(date +'%Y-%m-%d_%H:%M:%S')
#echo $TODAY
#echo $PNAME
#fswebcam -r 640x480 --no-banner ~/Pictures/usbcam_%Y-%m-%d_%H-%M-%S.jpg
#fswebcam -d /dev/video0 -i 0 -S 2 -r 640x480 --no-banner $PNAME -v
fswebcam -r 640x480 --no-banner $PNAME
gpicview $PNAME &
#echo "end fswebcam snap"

chmod +x

nano /home/pi/desktop/fswebcam.desktop
[Desktop Entry]
Comment=fswebcam snapshot
Name=fswebcam snap

play more GPICVIEW here

i read that MOTION not only handle the web cam, also makes a web server for it, so i try that too.
sudo apt-get install motion
from some internet info i also did
mkdir .motion
sudo cp /etc/motion/motion.conf ~/.motion/motion.conf
sudo nano ~/.motion/motion.conf

and then start with
sudo motion
my problem was that MY motion.conf was only used when i start
with "sudo motion" from this .motion subdir,
or when i start with "motion" but then it fails about the logfile creation....
so, i just deleted all that .motion again and edit
sudo nano /etc/motion/motion.conf
work on this lines:

if deamon is 'on' it will run as background service ( and i not find how to stop it / besides reboot )
if video codec mpeg4 you get a .AVI you can not watch, so change to mp4 can watch with
111 o 109 m 120 x 112 p 108 l 97 a 121 y 101 e 114 r
that player is installed and supports RPI hardware best,
test: omxplayer /opt/vc/src/hello_pi/hello_video/test.h264
but it is not included in the desktop system
____________VNC special___________________
( for realVNC must set /VNC-menu / Troubleshooting / enable experimental direct capture mode/ ..

____________end VNC___________________

so i play with the file manager "open with"

and not get it running but created chaos at the context menu

took me some time to find where that is located.
so i just delete:
rm /home/pi/.config/mimeapps.list
rm /home/pi/.local/share/applications/mimeinfo.cache
rm /home/pi/.local/share/applications/*.desktop
_________________start from terminal
pi@RPI2:/run/shm $ ls *.mp4
01-20170831093736.mp4 03-20170831094345.mp4 05-20170831094940.mp4
02-20170831094114.mp4 04-20170831094715.mp4 test.mp4
pi@RPI2:/run/shm $
pi@RPI2:/run/shm $ omxplayer --win '100 100 740 580' 02-20170831094114.mp4
Invalid framerate 2, using forced 25fps and just trust timestamps
Video codec omx-h264 width 320 height 240 profile 578 fps 25.000000
Subtitle count: 0, state: off, index: 1, delay: 0
V:PortSettingsChanged: 320x240@2.00 interlace:0 deinterlace:0 anaglyph:0 par:1.00 display:0 layer:0 alpha:255 aspectMode:0
have a nice day ;)
pi@RPI2:/run/shm $
so try context menu again ( and here even edit the .desktop file for double window size video )

from desktop also can open the stored .mp4 files via chromium browser as i can show in a snapshot,
but can not show the running OMXPLAYER window there!

if target_dir changed to /run/shm not worry about space.. but loose at shutdown/reboot

also i made a .desktop for start

( needed to find some good icon at the internet )

test browser: ( local )
video http://localhost:8081
center http://localhost:8080

if stream_localhost off can also use remote LAN PC:

as this was on STRETCH, here i did it again on JESSIE for 4um

RPI cam
82 R 80 P 73 I 32 space 99 c 97 a 109 m
as i play camera already,
why not also try PI camera again.
i repeatedly play with RPI1 and 5Mp original pi camera rev1.3 and this ( incl updated Raspbian OS ) but running it as a
"WIFI IP SEC CAM" never happy as the wifi connection drops and power cycle was needed.
( with ethernet cable not so many problems.. )
so that RPI1 plus the old cam was unused and collected dust, now i move the cam to this RPI2.

here a short linklist about RPI cam: hardware, RPI add ons, camera, getting started, use python and the forum

-a- first must enable camera by
sudo raspi-config
-b- test with a photo /snapshot ( like to /home/pi/Pictures/RPIcam.jpg ) and check it by filemanager.
-c- desktop integration:
nano /home/pi/Pictures/
TODAY=$(date +'%Y-%m-%d_%H:%M:%S')
#echo $TODAY
#echo $PNAME
raspistill -vf -n -w 640 -h 480 -o $PNAME -l $LNAME
gpicview $PNAME &
#echo "end RPIcam snap"

nano /home/pi/Desktop/RPIcam.desktop
[Desktop Entry]
Comment=RPI cam snap
Name=RPI cam

on click on the icon the camera led goes ON and after 2 sec OFF and the picture is opened at desktop
-a- i disable the preview
-b- i enable the last picture copy, so whenever open ( in that path ) RPIcam.jpg, it is the newest one.
-c- the ICON i downloaded from here

RPI cam by python:
-a- first i start to do same by a python3 program,
having a hard time about the {time} in filename, so i did it again in python3
idea is i start a python program what shows a cam preview 2sec (warmup) and then for 20sec
and if you press a [ctrl][c] a picture is saved and shown.
like here @4um

the default web server install for the RPI CAM is this

here i show how to start OMXplayer from python3

update 2018-04-28
i play with the opencv
and because both cameras are connected to my old RPI2 i try there and failed ( after 5hr. )
so cleaned up, start again, but this time with same SD card in my RPI3.

follow here and here

sudo apt install build-essential cmake pkg-config
sudo apt install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt install libxvidcore-dev libx264-dev
sudo apt install libgtk2.0-dev libgtk-3-dev
sudo apt install libatlas-base-dev gfortran
sudo apt install python2.7-dev python3-dev # already ok

# get the code
cd ~
wget -O
# there is also a i try next time
wget -O

# use the virtual environment thing first time
sudo pip install virtualenv virtualenvwrapper
sudo rm -rf ~/.cache/pip
nano ~/.profile # and add at end:
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/

sudo nano /etc/dphys-swapfile
( reboot )
mkvirtualenv cv -p python
( reboot )
source ~/.profile
workon cv

# get NUMPY
pip install numpy # takes long

# make opencv
cd ~/opencv-3.3.0/
mkdir build
cd build
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules \

make -j4

sudo make install
sudo ldconfig

# softlink
ls -l /usr/local/lib/python2.7/site-packages/
cd ~/.virtualenvs/cv/lib/python2.7/site-packages/
ln -s /usr/local/lib/python2.7/site-packages/

>>> import cv2
>>> cv2.__version__

# clean up
rm -rf opencv-3.3.0 opencv_contrib-3.3.0
rm # and the zip

nano /etc/dphys-swapfile
# change back
( reboot )

take SD card back in RPI2 and test again!
( looks ok after 2h 54min )

start work after search here and here and here and here and here

i want play later: stream

screen cast
115 s 99 c 114 r 101 e 101 e 110 n 32 space 99 c 97 a 115 s 116 t
a other VIDEO question i had when i try to do a video for the THEREMIN test.
the TV screenshot by my tablet ( android ) is terrible.
so, how to do a screen cast forum, AND
as it contains several windows on the (HDMI) RPI AND HDMI sound output
a win7 PC VNC windows shot will never cover that sound.
but lets start slowly:
the video software ffmpeg now get with:
sudo apt-get install -y libav-tools
sudo raspi-config set resolution DMT 39 1360x768
~/Videos $ avconv -f x11grab -r 5 -s 1360x768 -i :0.0 out.avi
say 'y' to overwrite out.avi file if already exists
say 'q' to stop recording
to replay the recording ( half screen size ) use
~/Videos $ omxplayer --win "100 100 780 484" out.avi

found this: SSR
sudo apt-get install -y simplescreenrecorder
nice and easy menu / plus header icon /
- - sound recording also not work / must be disabled

to play video still search for GUI
all time i see omxplayerGUI but how to do it??
seems to only go via KWEB
as for today 2018_03_24
Installation for Stretch

tar -xzf kweb-
cd kweb-
ok find
[menu][internet][minimal kiosk browser]
[menu][sound & video][omxplayerGUI]

screen shot
115 s 99 c 114 r 101 e 101 e 110 n 115 s 104 h 111 o 116 t
until now i used SCROT for screen shots but that can not catch a OMXplayer window
( what works via VNC on PC )
but at forum got the link to raspi2png

sudo raspi-config
7 advanced options
A3 memory split
ok reboot

sudo apt-get install libpng12-dev
cd /home/pi/projects/
git clone
cd raspi2png
i first try:
alias snappi="/home/pi/projects/raspi2png/raspi2png -p /home/pi/Desktop/share/snappi.png"
but see i need a script
now=$(date +"%Y_%m_%d_%H_%M_%S")

#echo $SNAPPI
#echo "find: "$IFILENAME
#gpicview $IFILENAME &

nano /home/pi/.bash_aliases add line:
alias snappi="/home/pi/projects/raspi2png/"
also do a
nano snappi.desktop[Desktop Entry]
Comment=start raspi2png

more options in script:
now=$(date +"%Y_%m_%d_%H_%M_%S")

#echo $SNAPPI

env sleep 1
echo "find: "$IFILENAME
echo -n "press [y][Y] for view picture, timeout 5s"
# timeout, one character input only / no ENTER required
read -t 5 -n 1 -p '? ' MYANSWER
case $MYANSWER in
[Yy]*) echo ' You said: yes'
gpicview $IFILENAME &
echo 'press ENTER' # also closes gpicview window
read ;;
[Nn]*) echo ' You said: no';;
[Qq]*) echo ' You said: quit';;
*) echo ' !wrong answer or timeout';;