Hi guys
I was following this Tutorial: https://www.raspberrypi.com/tutorials/p ... sb-webcam/ to build a Raspberry Pi webcam. I purchased a Pi Zero 2 W and Camera-board V3 (normal) to build it into an old Apple iSight camera.
All works, however my Camera-board is rotated by 90 degrees, so my image is as well. I couldn't find how I could rotate the image in SW on the Pi. Can someone help me please?
Below is the code for the Webcam
kind Regards
Working1010
I was following this Tutorial: https://www.raspberrypi.com/tutorials/p ... sb-webcam/ to build a Raspberry Pi webcam. I purchased a Pi Zero 2 W and Camera-board V3 (normal) to build it into an old Apple iSight camera.
All works, however my Camera-board is rotated by 90 degrees, so my image is as well. I couldn't find how I could rotate the image in SW on the Pi. Can someone help me please?
Below is the code for the Webcam
kind Regards
Working1010
Code:
#!/bin/bash# Variables we need to make things easier later on.CONFIGFS="/sys/kernel/config"GADGET="$CONFIGFS/usb_gadget"VID="0x0525"PID="0xa4a2"SERIAL="0123456789"MANUF=$(hostname)PRODUCT="UVC Gadget"BOARD=$(strings /proc/device-tree/model)UDC=`ls /sys/class/udc` # will identify the 'first' UDC# Later on, this function is used to tell the usb subsystem that we want# to support a particular format, framesize and frameintervalscreate_frame() {# Example usage:# create_frame <function name> <width> <height> <format> <name> <intervals>FUNCTION=$1WIDTH=$2HEIGHT=$3FORMAT=$4NAME=$5wdir=functions/$FUNCTION/streaming/$FORMAT/$NAME/${HEIGHT}pmkdir -p $wdirecho $WIDTH > $wdir/wWidthecho $HEIGHT > $wdir/wHeightecho $(( $WIDTH * $HEIGHT * 2 )) > $wdir/dwMaxVideoFrameBufferSizecat <<EOF > $wdir/dwFrameInterval$6EOF}# This function sets up the UVC gadget function in configfs and binds us# to the UVC gadget driver.create_uvc() {CONFIG=$1FUNCTION=$2echo "Creating UVC gadget functionality : $FUNCTION"mkdir functions/$FUNCTIONcreate_frame $FUNCTION 640 480 uncompressed u "333333416667500000666666100000013333332000000"create_frame $FUNCTION 1280 720 uncompressed u "100000013333332000000"create_frame $FUNCTION 1920 1080 uncompressed u "2000000"create_frame $FUNCTION 640 480 mjpeg m "333333416667500000666666100000013333332000000"create_frame $FUNCTION 1280 720 mjpeg m "333333416667500000666666100000013333332000000"create_frame $FUNCTION 1920 1080 mjpeg m "333333416667500000666666100000013333332000000"mkdir functions/$FUNCTION/streaming/header/hcd functions/$FUNCTION/streaming/header/hln -s ../../uncompressed/uln -s ../../mjpeg/mcd ../../class/fsln -s ../../header/hcd ../../class/hsln -s ../../header/hcd ../../class/ssln -s ../../header/hcd ../../../controlmkdir header/hln -s header/h class/fsln -s header/h class/sscd ../../../# This configures the USB endpoint to allow 3x 1024 byte packets per# microframe, which gives us the maximum speed for USB 2.0. Other# valid values are 1024 and 2048, but these will result in a lower# supportable framerate.echo 2048 > functions/$FUNCTION/streaming_maxpacketln -s functions/$FUNCTION configs/c.1}# This loads the module responsible for allowing USB Gadgets to be# configured through configfs, without which we can't connect to the# UVC gadget kernel driverecho "Loading composite module"modprobe libcomposite# This section configures the gadget through configfs. We need to# create a bunch of files and directories that describe the USB# device we want to pretend to be.if[ ! -d $GADGET/g1 ]; thenecho "Detecting platform:"echo " board : $BOARD"echo " udc : $UDC"echo "Creating the USB gadget"echo "Creating gadget directory g1"mkdir -p $GADGET/g1cd $GADGET/g1if[ $? -ne 0 ]; thenecho "Error creating usb gadget in configfs"exit 1;elseecho "OK"fiecho "Setting Vendor and Product ID's"echo $VID > idVendorecho $PID > idProductecho "OK"echo "Setting English strings"mkdir -p strings/0x409echo $SERIAL > strings/0x409/serialnumberecho $MANUF > strings/0x409/manufacturerecho $PRODUCT > strings/0x409/productecho "OK"echo "Creating Config"mkdir configs/c.1mkdir configs/c.1/strings/0x409echo "Creating functions..."create_uvc configs/c.1 uvc.0echo "OK"echo "Binding USB Device Controller"echo $UDC > UDCecho "OK"fi# Run uvc-gadget. The -c flag sets libcamera as a source, arg 0 selects# the first available camera on the system. All cameras will be listed,# you can re-run with -c n to select camera n or -c ID to select via# the camera ID.uvc-gadget -c 0 uvc.0
Statistics: Posted by working1010 — Fri Apr 19, 2024 9:52 am — Replies 0 — Views 10