connect webcam to beaglebone
TRANSCRIPT
-
8/10/2019 Connect Webcam to Beaglebone
1/10
Connecting WebCam to BeagleboneBlack
fswebcam is a small and simple webcam app. It can capture images froma number of different sources and perform simple manipulation on
the captured image. The image can be saved as one or more PNG or JPEGfiles.
Installing fswebcam
Firstly, we need to update the system> sudo apt-get update
>sudo apt-get upgrade
Now installing fswebcam from ubuntu base repository
>sudo apt-get install -y fswebcam
Checking available Camera
> ls -ltrh /dev/video*
it will show all the camera present on you BeagleBoneBlack or ubuntu pc
-
8/10/2019 Connect Webcam to Beaglebone
2/10
Testing fswebcam
> fswebcam -r 320x240 -d /dev/video0 capture.jpg
Saving Multiple Screenshots in loop
save this script in .su extension and give that 777 permission rights. And
run that to start capturing frame for time lapse. Change the directoriesasper your script location and where you want to save the jpg file.
#!/bin/bash#time-lapse video frame
width=320height=240interval=4
output=/home/ubuntu32/Desktop/fswebcam/inprocess.jpg
capture=/home/ubuntu32/Desktop/fswebcam/capture.su#
# Uncomment the following lines if using uvccapture.#
# brightness=96
-
8/10/2019 Connect Webcam to Beaglebone
3/10
# saturation=32
# contrast=32
# gain=16# exec uvccapture -v -m -t$((interval)) \
# -B$brightness -S$saturation -C$contrast -G$gain \# -c$capture \
# -x$width -y$height -o$output## Comment out the following lines if using uvccapture.
#font=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
exec fswebcam --quiet --skip 14 \
--font $font \--timestamp '%d %b %y %H:%M:%S (%Z)' \
--no-title -r $height\x$width \--banner-colour '#FF000000' \
--line-colour '#FF000000' \--exec $capture \
--loop $interval $output#renaming
timestamp=$(date -u +"%y%m%d-%H:%M:%S")image=/home/ubuntu32/Desktop/fswebcam/inprocess.jpg
output=/home/ubuntu32/Desktop/fswebcam/capture-$timestamp.jpgcp $image $output
>chmod +x script_name.su
>./script_name.su
sample fswebcam directory view
-
8/10/2019 Connect Webcam to Beaglebone
4/10
You can even remove #tag from script to change the preferences of capturingframe and also can include following predefine function in library of
fswebcam to edit the script.
ConfigurationFileConfig files use the long version of options without the "--" prefix.
Comments start with a # symbol at the beginning of the line.
GeneralOptions
-?, --helpShow a usage summary.
-c, --configLoad options from a file. You can load more than one configfile, and can mix them with command-line arguments.
Note: This option can not be used from within a configurationfile.
-q, --quietHides all messages except errors.
-v, --verbosePrint extra information during the capture process.
--version
Print the version number and exit.
-l, --loopContinually capture images. The time between images is specified
in seconds.
Default behaviour is to capture a single image and exit.
Note: The time to capture the next image is calculated relative
to the epoch, so an image will not be captured immediately whenthe program is first started.
--offset
Sets the offset to use when calculating when the next image isdue in loop mode. Value can be positive or negative.
-b, --backgroundRun in the background. In this mode stdout and console loggingare unavailable.
--pidSaves the PID of the background process to the specified file.Ignored when not using background mode.
-
8/10/2019 Connect Webcam to Beaglebone
5/10
--log[file/syslog:]
Redirect log messages to a file or syslog. For example
--log output.log--log file:output.log
--log syslog
--gmt Use GMT instead of the local timezone when formatting text withstrftime.
CaptureOptions-d, --device[:]
Set the source or device to use. The source module is selected
automatically unless specified in the prefix.
Default is /dev/video0.
Available source modules, in order of preference:
V4L2 - Capture images from a V4L2 compatible video device.
V4L1 - Capture images from a V4L1 compatible video device.FILE - Capture an image from a JPEG or PNG image file.RAW - Reads images straight from a device or file.TEST - Draws colour bars.
-i, --input
Set the input to use. You may select an input by either its
number or name.
Default is "0".
--list-inputs
List available inputs for the selected source or device.
fswebcam -d v4l2:/dev/video1 --list-inputs
-t, --tunerSet the tuner to use.
-f, --frequencySet the frequency of the selected input or tuner. The value may
be read as KHz or MHz depending on the input or tuner.
-p, --paletteTry to use the specified image format when capturing the image.
Default is to select one automatically.
Supported formats:
PNGJPEG
MJPEG
RGB32RGB24
BGR32
-
8/10/2019 Connect Webcam to Beaglebone
6/10
BGR24YUYV
UYVYYUV420PBAYERRGB565
RGB555
GREY
-r, --resolutionSet the image resolution of the source or device. The actualresolution used may differ if the source or device cannotcapture at the specified resolution.
Default is "384x288".
--list-framesizes
Lists the supported resolutions for the selected source.
--list-framerates
Lists the supported frame rates for the selected source and
resolution.
-F, --framesSet the number of frames to capture. More frames mean less noise
in the final image, however capture times will be longer andmoving objects may appear blurred.
Default is "1".
-S, --skipSet the number of frames to skip. These frames will be capturedbut wont be use. Use this option if your camera sends some bador corrupt frames when it first starts capturing.
Default is "0".
-D, --delayInserts a delay after the source or device has been opened and
initialised, and before the capture begins. Some devices needthis delay to let the image settle after a setting has changed.The delay time is specified in seconds.
-R, --readUse read() to capture images. This can be slower but more stablewith some devices.
Default is to use mmap(), falling back on read() if mmap() isunavailable.
-s, --setSet a control. These are used by the source modules to controlimage or device parameters. Numeric values can be expressed as a
percentage of there maximum range or a literal value, for
example:
--set brightness=50% --set framerate=5
-
8/10/2019 Connect Webcam to Beaglebone
7/10
Non-numeric controls are also supported:
--set lights=on
V4L2 features a type of control called a button. These
controls do not take any value, but trigger an action. For
example:
--set "Restore Factory Settings"
Control names and values are not case sensitive.
Note: Available controls will vary depending in the source
module and devices used. For more information see the--list-controlsoption.
--list-controls
List available controls and their current values for theselected source module and device. For example:
fswebcam -d v4l2:/dev/video2 --list-controls
OutputOptionsThese options are performed in the order they appear on the command
line, only effecting images output later on the command line. Forexample:
fswebcam -r 640x480 output1.jpeg --scale 320x240 output2.jpeg
Will create two images, "output1.jpeg" containing a fullresolution copy of the captured image and "output2.jpeg"
containing the same captured image but scaled to half the size.
--no-bannerDisable the banner.
--top-banner
Position the banner at the top of the image.
--bottom-banner
Position the banner at the bottom of the image.
This is the default.
--banner-colour
Set the colour of the banner. Uses the web-style hexadecimal
format (#RRGGBB) to describe the colour, and can support analpha channel (#AARRGGBB). Examples:
"#FF0000" is pure red."#80000000" is semi-transparent black."#FF000000" is invisible (alpha channel is at maximum).
Default is "#40263A93".
--line-colour
Set the colour of the divider line. See --banner-colourfor more
-
8/10/2019 Connect Webcam to Beaglebone
8/10
information.
Default is "#00FF0000".
--text-colourSet the colour of the text. See --banner-colour for more
information.
Default is "#00FFFFFF".
--fontSet the font used in the banner. If no path is specified thepath in the GDFONTPATH environment variable is searched for the
font.
If no font size is specified the default of "10" will be used.
Default is "luxisr:10".
--no-shadow
Disable the text shadow.
--shadow
Enable the text shadow.
This is the default behaviour.
--title
Set the main text, located in the top left of the banner.
--no-title
Clear the main text.
--subtitle
Set the sub-title text, located in the bottom left of thebanner.
--no-subtitle
Clear the sub-title text.
--timestampSet the timestamp text, located in the top right of the banner.
This string is formatted by strftime.
Default is "%Y-%m-%d %H:%M (%Z)".
--no-timestamp
Clear the timestamp text.
--infoSet the info text, located in the bottom right of the banner.
--no-info
Clear the info text.
--underlay
Load a PNG image and overlay it on the image, below the banner.
-
8/10/2019 Connect Webcam to Beaglebone
9/10
The image is aligned to the top left.
Note: The underlay is only applied when saving an image and isnot modified by any of the image options or effects.
--no-underlay
Clear the underlay image.
--overlayLoad a PNG image and overlay on the image, above the banner. Theimage is aligned to the top left.
Note: The overlay is only applied when saving an image and is
not modified by any of the image options or effects.
--no-overlay
Remove the overlay image.
--jpegSet JPEG as the output image format. The compression factor is a
value between 0 and 95, or -1 for automatic.
This is the default format, with a factor of "-1".
--png
Set PNG as the output image format. The compression factor canbe a value between 0 and 9, or -1 for automatic.
--saveSaves the image to the specified filename.
Note: This isnt necessary on the command-line where a filename
alone is enough to save an image.
--revertRevert to the original captured image and resolution. Thisundoes all previous effects on the image.
Note: This only reverts the image itself, and not options such
as font, colours and overlay.
--flip
Flips the image. Direction can be (h)orizontal or (v)ertical.Example:
--flip h Flips the image horizontally.
--flip h,v Flips the image both horizontally and vertically.
--crop
Crop the image. With no offset the cropped area will be thecenter of the image. Example:
--crop 320x240 Crops the center 320x240 area of the image.
--crop 10x10,0x0 Crops the 10x10 area at the top left corner of
the image.
--scale
-
8/10/2019 Connect Webcam to Beaglebone
10/10
Scale the image.
Example: "--scale 640x480" scales the image up or down to640x480.
Note: The aspect ratio of the image is not maintained.
--rotate
Rotate the image in right angles (90, 180 and 270 degrees).
Note: Rotating the image 90 or 270 degrees will swap thedimensions.
--deinterlace
Apply a simple deinterlacer to the image.
--invert
Invert all the colours in the image, creating a negative.
--exec
Executes the specified command and waits for it to complete
before continuing. The command line is formatted by strftime.