Hello,
I've managed to turn my Pi into a webcam following this tutorial : https://www.raspberrypi.com/tutorials/p ... sb-webcam/
In this tutorial, they use another Pi camera, so in the code it only goes to 1920 x 1080 pixels but the HQ camera goes to 3280 × 2464 pixels !
I think it has to do with the script code, here it is :
As you can see, the only lines that mention the resolution only go to 1920 x 1080p, how can I change that so my HQ camera can stream 3280 × 2464p ? Thank you !!
I've managed to turn my Pi into a webcam following this tutorial : https://www.raspberrypi.com/tutorials/p ... sb-webcam/
In this tutorial, they use another Pi camera, so in the code it only goes to 1920 x 1080 pixels but the HQ camera goes to 3280 × 2464 pixels !
I think it has to do with the script code, here it is :
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 Oceanique — Tue Feb 27, 2024 2:08 pm