Aug 19 2017
RPI with USB CAM + RPI_CAM +Screenshot
USB camfswebcam
MOTION
OMXplayer
RPI cam
screen cast
screen shot
USB cam
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.
fswebcam
update:
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
nano fswebcamsnap.sh
#!/bin/bash
TODAY=$(date +'%Y-%m-%d_%H:%M:%S')
#echo $TODAY
PNAME='/home/pi/Pictures/usbcam_'$TODAY'.jpg'
#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"
TODAY=$(date +'%Y-%m-%d_%H:%M:%S')
#echo $TODAY
PNAME='/home/pi/Pictures/usbcam_'$TODAY'.jpg'
#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 fswebcamsnap.sh
nano /home/pi/desktop/fswebcam.desktop
[Desktop Entry]
Type=Application
Comment=fswebcam snapshot
Name=fswebcam snap
Icon=/home/pi/Downloads/web_camera_32.png
Exec=/home/pi/Pictures/fswebcamsnap.sh
Type=Application
Comment=fswebcam snapshot
Name=fswebcam snap
Icon=/home/pi/Downloads/web_camera_32.png
Exec=/home/pi/Pictures/fswebcamsnap.sh
play more GPICVIEW here
MOTION
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
OMXplayer
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
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/RPIcamsnap.sh
#!/bin/bash
TODAY=$(date +'%Y-%m-%d_%H:%M:%S')
#echo $TODAY
PNAME='/home/pi/Pictures/RPIcam_'$TODAY'.jpg'
#echo $PNAME
LNAME='/home/pi/Pictures/RPIcam.jpg'
raspistill -vf -n -w 640 -h 480 -o $PNAME -l $LNAME
gpicview $PNAME &
#echo "end RPIcam snap"
TODAY=$(date +'%Y-%m-%d_%H:%M:%S')
#echo $TODAY
PNAME='/home/pi/Pictures/RPIcam_'$TODAY'.jpg'
#echo $PNAME
LNAME='/home/pi/Pictures/RPIcam.jpg'
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]
Type=Application
Comment=RPI cam snap
Name=RPI cam
Icon=/home/pi/Downloads/web_camera_32.png
Exec=/home/pi/Pictures/RPIcamsnap.sh
Type=Application
Comment=RPI cam snap
Name=RPI cam
Icon=/home/pi/Downloads/web_camera_32.png
Exec=/home/pi/Pictures/RPIcamsnap.sh
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 opencv.zip https://github.com/Itseez/opencv/archive/3.3.0.zip
# there is also a 3.4.0.zip i try next time
unzip opencv.zip
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
unzip opencv_contrib.zip
# 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/virtualenvwrapper.sh
#SWAP
sudo nano /etc/dphys-swapfile
# CONF_SWAPSIZE=100
CONF_SWAPSIZE=1024
( 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
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules \
-D BUILD_EXAMPLES=ON ..
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/cv2.so cv2.so
#test
python3
>>> import cv2
>>> cv2.__version__
# clean up
rm -rf opencv-3.3.0 opencv_contrib-3.3.0
rm opencv_contrib.zip opencv.zip # 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
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
wget http://steinerdatenbank.de/software/kweb-1.7.9.8.tar.gz
tar -xzf kweb-1.7.9.8.tar.gz
cd kweb-1.7.9.8
./debinstall
________________________
ok find
[menu][internet][minimal kiosk browser]
[menu][sound & video][omxplayerGUI]
screen shot
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
128
ok reboot
sudo apt-get install libpng12-dev
cd /home/pi/projects/
git clone https://github.com/AndrewFromMelbourne/raspi2png.git
cd raspi2png
make
i first try:
alias snappi="/home/pi/projects/raspi2png/raspi2png -p /home/pi/Desktop/share/snappi.png"
but see i need a script
nano /home/pi/.bash_aliases add line:
alias snappi="/home/pi/projects/raspi2png/snappi.sh"
also do a

more options in script:

