Articles Hierarchy

Articles Home » RPI » RPI with old USB CAM

RPI with old 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.


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"

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



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



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/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"

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

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.