added my Recipes
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
Application:
|
||||
Name: Camera
|
||||
Description: preview
|
||||
Icon: application/camera/pictures/ST1077_webcam_dark_blue.png
|
||||
Board:
|
||||
List: all
|
||||
Type: script
|
||||
Script:
|
||||
Exist:
|
||||
Command: /usr/local/demo/application/camera/bin/check_camera_preview.sh
|
||||
Msg_false: Webcam or camera is not connected
|
||||
Start: application/camera/bin/launch_camera_preview.sh
|
||||
Action:
|
||||
button_release_event: script_management
|
||||
button_press_event: highlight_eventBox
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
is_dcmipp_present() {
|
||||
DCMIPP_PRESENT="NOTFOUND"
|
||||
# on disco board gc2145 or ov5640 camera can be present on csi connector
|
||||
for video in $(find /sys/class/video4linux -name "video*" -type l);
|
||||
do
|
||||
if [ "$(cat $video/name)" = "dcmipp_dump_capture" ]; then
|
||||
for sub in $(find /sys/class/video4linux -name "v4l-subdev*" -type l);
|
||||
do
|
||||
subdev_name=$(tr -d '\0' < $sub/name | awk '{print $1}')
|
||||
if [ "$subdev_name" = "gc2145" ] || [ "$subdev_name" = "ov5640" ]; then
|
||||
DCMIPP_PRESENT="FOUND"
|
||||
return
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
get_webcam_device() {
|
||||
WEBCAM_found="NOTFOUND"
|
||||
for video in $(find /sys/class/video4linux -name "video*" -type l | sort);
|
||||
do
|
||||
if [ ! "$(cat $video/name)" = "dcmipp_dump_capture" ]; then
|
||||
WEBCAM_found="FOUND"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ------------------------------
|
||||
# main
|
||||
# ------------------------------
|
||||
|
||||
# camera detection
|
||||
# detect if we have a gc2145 or ov5640 plugged and associated to dcmipp
|
||||
is_dcmipp_present
|
||||
if [ "$DCMIPP_PRESENT" = "FOUND" ]; then
|
||||
exit 0
|
||||
fi
|
||||
get_webcam_device
|
||||
if [ "$WEBCAM_found" = "FOUND" ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Original shader from: https://www.shadertoy.com/view/MdGXDy
|
||||
*
|
||||
* Automatically converted by st-to-gstsh script
|
||||
* See: https://github.com/jolivain/gst-shadertoy
|
||||
*/
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
// gst-glshader uniforms
|
||||
uniform float time;
|
||||
uniform float width;
|
||||
uniform float height;
|
||||
uniform sampler2D tex;
|
||||
|
||||
// shadertoy globals
|
||||
float iGlobalTime = 0.0;
|
||||
float iTime = 0.0;
|
||||
vec3 iResolution = vec3(0.0);
|
||||
vec3 iMouse = vec3(0.0);
|
||||
vec4 iDate = vec4(0.0);
|
||||
|
||||
#define iChannel0 tex
|
||||
#define texture(t,c) texture2D(t,c)
|
||||
#if (__VERSION__ < 300)
|
||||
# define textureLod(s, uv, l) texture2D(s, uv)
|
||||
#endif
|
||||
|
||||
// Protect gst-glshader names
|
||||
#define time gstemu_time
|
||||
#define width gstemu_width
|
||||
#define height gstemu_height
|
||||
|
||||
// --------[ Original ShaderToy begins here ]---------- //
|
||||
const float gamma = 2.2;
|
||||
|
||||
float gamma2linear( float v )
|
||||
{
|
||||
return pow( v, gamma );
|
||||
}
|
||||
|
||||
float linear2gamma( float v )
|
||||
{
|
||||
return pow( v, 1./gamma );
|
||||
}
|
||||
|
||||
float min3( float a, float b, float c )
|
||||
{
|
||||
return min( min( a, b ), c );
|
||||
}
|
||||
|
||||
float max3( float a, float b, float c )
|
||||
{
|
||||
return max( max( a, b ), c );
|
||||
}
|
||||
|
||||
vec3 rgb2hsv(vec3 c)
|
||||
{
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
vec3 hsv2rgb(vec3 c)
|
||||
{
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
vec3 convertRGBtoHSL( vec3 col )
|
||||
{
|
||||
float red = col.r;
|
||||
float green = col.g;
|
||||
float blue = col.b;
|
||||
|
||||
float minc = min3( col.r, col.g, col.b );
|
||||
float maxc = max3( col.r, col.g, col.b );
|
||||
float delta = maxc - minc;
|
||||
|
||||
float lum = (minc + maxc) * 0.5;
|
||||
float sat = 0.0;
|
||||
float hue = 0.0;
|
||||
|
||||
if (lum > 0.0 && lum < 1.0) {
|
||||
float mul = (lum < 0.5) ? (lum) : (1.0-lum);
|
||||
sat = delta / (mul * 2.0);
|
||||
}
|
||||
|
||||
vec3 masks = vec3(
|
||||
(maxc == red && maxc != green) ? 1.0 : 0.0,
|
||||
(maxc == green && maxc != blue) ? 1.0 : 0.0,
|
||||
(maxc == blue && maxc != red) ? 1.0 : 0.0
|
||||
);
|
||||
|
||||
vec3 adds = vec3(
|
||||
((green - blue ) / delta),
|
||||
2.0 + ((blue - red ) / delta),
|
||||
4.0 + ((red - green) / delta)
|
||||
);
|
||||
|
||||
float deltaGtz = (delta > 0.0) ? 1.0 : 0.0;
|
||||
|
||||
hue += dot( adds, masks );
|
||||
hue *= deltaGtz;
|
||||
hue /= 6.0;
|
||||
|
||||
if (hue < 0.0)
|
||||
hue += 1.0;
|
||||
|
||||
return vec3( hue, sat, lum );
|
||||
}
|
||||
|
||||
vec3 convertHSLtoRGB( vec3 col )
|
||||
{
|
||||
const float onethird = 1.0 / 3.0;
|
||||
const float twothird = 2.0 / 3.0;
|
||||
const float rcpsixth = 6.0;
|
||||
|
||||
float hue = col.x;
|
||||
float sat = col.y;
|
||||
float lum = col.z;
|
||||
|
||||
vec3 xt = vec3(
|
||||
rcpsixth * (hue - twothird),
|
||||
0.0,
|
||||
rcpsixth * (1.0 - hue)
|
||||
);
|
||||
|
||||
if (hue < twothird) {
|
||||
xt.r = 0.0;
|
||||
xt.g = rcpsixth * (twothird - hue);
|
||||
xt.b = rcpsixth * (hue - onethird);
|
||||
}
|
||||
|
||||
if (hue < onethird) {
|
||||
xt.r = rcpsixth * (onethird - hue);
|
||||
xt.g = rcpsixth * hue;
|
||||
xt.b = 0.0;
|
||||
}
|
||||
|
||||
xt = min( xt, 1.0 );
|
||||
|
||||
float sat2 = 2.0 * sat;
|
||||
float satinv = 1.0 - sat;
|
||||
float luminv = 1.0 - lum;
|
||||
float lum2m1 = (2.0 * lum) - 1.0;
|
||||
vec3 ct = (sat2 * xt) + satinv;
|
||||
|
||||
vec3 rgb;
|
||||
if (lum >= 0.5)
|
||||
rgb = (luminv * ct) + lum2m1;
|
||||
else rgb = lum * ct;
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||
{
|
||||
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||
vec3 sample = texture( iChannel0, uv ).rgb;
|
||||
|
||||
vec3 s2 = convertRGBtoHSL( sample );
|
||||
|
||||
//s2.b = gamma2linear( s2.b );
|
||||
s2.b = ( s2.b * -1.0 ) + 1.0;
|
||||
//s2.b = linear2gamma( s2.b );
|
||||
|
||||
vec3 s3 = convertHSLtoRGB( s2 );
|
||||
fragColor = vec4(s3, 1.0);
|
||||
}
|
||||
// --------[ Original ShaderToy ends here ]---------- //
|
||||
|
||||
#undef time
|
||||
#undef width
|
||||
#undef height
|
||||
|
||||
void main(void)
|
||||
{
|
||||
iResolution = vec3(width, height, 0.0);
|
||||
iGlobalTime = time;
|
||||
iTime = time;
|
||||
iDate.w = time;
|
||||
|
||||
mainImage(gl_FragColor, gl_FragCoord.xy);
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
#!/bin/sh
|
||||
function print_debug() {
|
||||
echo "[exec]: $@"
|
||||
}
|
||||
|
||||
function pty_exec() {
|
||||
cmd=$1
|
||||
pty=$(tty > /dev/null 2>&1; echo $?)
|
||||
if [ $pty -eq 0 ]; then
|
||||
cmd=$(echo $cmd | sed "s#\"#'#g")
|
||||
event_cmd=$(echo /usr/local/demo/bin/touch-event-gtk-player -w $SCREEN_WIDTH -h $SCREEN_HEIGHT --graph \"$cmd\")
|
||||
eval $event_cmd > /dev/null 2>&1
|
||||
else
|
||||
# no pty
|
||||
echo "NO PTY"
|
||||
event_cmd=$(echo /usr/local/demo/bin/touch-event-gtk-player -w $SCREEN_WIDTH -h $SCREEN_HEIGHT --graph \'$cmd\')
|
||||
script -qc "$event_cmd" > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
is_dcmipp_present() {
|
||||
DCMIPP_SENSOR="NOTFOUND"
|
||||
# on disco board ov5640 camera can be present on csi connector
|
||||
for video in $(find /sys/class/video4linux -name "video*" -type l);
|
||||
do
|
||||
if [ "$(cat $video/name)" = "dcmipp_dump_capture" ]; then
|
||||
cd $video/device/
|
||||
mediadev=/dev/$(ls -d media*)
|
||||
cd -
|
||||
for sub in $(find /sys/class/video4linux -name "v4l-subdev*" -type l);
|
||||
do
|
||||
subdev_name=$(tr -d '\0' < $sub/name | awk '{print $1}')
|
||||
if [ "$subdev_name" = "gc2145" ] || [ "$subdev_name" = "ov5640" ]; then
|
||||
DCMIPP_SENSOR=$subdev_name
|
||||
V4L_DEVICE="device=/dev/$(basename $video)"
|
||||
sensorsubdev=$(tr -d '\0' < $sub/name)
|
||||
#bridge is connected to output of sensor (":0 [ENABLED" with media-ctl -p)
|
||||
bridgesubdev=$(media-ctl -d $mediadev -p -e "$sensorsubdev" | grep ":0 \[ENABLED" | awk -F\" '{print $2}')
|
||||
#interface is connected to input of postproc (":1 [ENABLED" with media-ctl -p)
|
||||
interfacesubdev=$(media-ctl -d $mediadev -p -e "dcmipp_dump_postproc" | grep ":1 \[ENABLED" | awk -F\" '{print $2}')
|
||||
if [ "$subdev_name" = "gc2145" ]; then
|
||||
sensorbuscode_constrain="BE"
|
||||
parallelbuscode="RGB565_2X8_BE"
|
||||
else
|
||||
sensorbuscode_constrain="LE"
|
||||
parallelbuscode="RGB565_2X8_LE"
|
||||
fi
|
||||
echo "media device: "$mediadev
|
||||
echo "video device: "$V4L_DEVICE
|
||||
echo "sensor subdev: " $sensorsubdev
|
||||
echo "bridge subdev: " $bridgesubdev
|
||||
echo "interface subdev: " $interfacesubdev
|
||||
|
||||
return
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
is_dcmi_present() {
|
||||
DCMI_SENSOR="NOTFOUND"
|
||||
# on disco board ov5640 camera can be present on // connector
|
||||
for video in $(find /sys/class/video4linux -name "video*" -type l);
|
||||
do
|
||||
if [ "$(cat $video/name)" = "stm32_dcmi" ]; then
|
||||
V4L_DEVICE="device=/dev/$(basename $video)"
|
||||
DCMI_SENSOR="$(basename $video)"
|
||||
echo "video DCMI device: "$V4L_DEVICE
|
||||
return
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
get_webcam_device() {
|
||||
found="NOTFOUND"
|
||||
for video in $(find /sys/class/video4linux -name "video*" -type l | sort);
|
||||
do
|
||||
if [ "$(cat $video/name)" = "dcmipp_dump_capture" ]; then
|
||||
found="FOUND"
|
||||
else
|
||||
V4L_DEVICE="device=/dev/$(basename $video)"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ------------------------------
|
||||
# main
|
||||
# ------------------------------
|
||||
|
||||
# graphic brackend detection
|
||||
if [ -f /etc/default/weston ] && $(grep "^OPTARGS" /etc/default/weston | grep -q "use-pixman" ) ;
|
||||
then
|
||||
echo "Without GPU"
|
||||
ADDONS="videoconvert ! queue !"
|
||||
else
|
||||
echo "With GPU"
|
||||
ADDONS=""
|
||||
fi
|
||||
|
||||
|
||||
# Detect size of screen
|
||||
SCREEN_WIDTH=$(wayland-info | grep logical_width | sed -r "s/logical_width: ([0-9]+),.*/\1/")
|
||||
SCREEN_HEIGHT=$(wayland-info | grep logical_width | sed -r "s/.*logical_height: ([0-9]+).*/\1/")
|
||||
|
||||
|
||||
# camera detection
|
||||
is_dcmipp_present
|
||||
if [ "$DCMIPP_SENSOR" != "NOTFOUND" ]; then
|
||||
WIDTH=640
|
||||
HEIGHT=480
|
||||
FPS=30
|
||||
|
||||
sensordev=$(media-ctl -d $mediadev -p -e "$sensorsubdev" | grep "node name" | awk -F\name '{print $2}')
|
||||
sensorbuscode=`v4l2-ctl --list-subdev-mbus-codes -d $sensordev | grep RGB565 | grep "$sensorbuscode_constrain" | awk -FMEDIA_BUS_FMT_ '{print $2}'| head -n 1`
|
||||
echo "sensor mbus-code: "$sensorbuscode
|
||||
print_debug media-ctl -d $mediadev --set-v4l2 "'$sensorsubdev':0[fmt:$sensorbuscode/${WIDTH}x${HEIGHT}@1/${FPS} field:none]"
|
||||
media-ctl -d $mediadev --set-v4l2 "'$sensorsubdev':0[fmt:$sensorbuscode/${WIDTH}x${HEIGHT}@1/${FPS} field:none]"
|
||||
print_debug media-ctl -d $mediadev --set-v4l2 "'$bridgesubdev':2[fmt:$sensorbuscode/${WIDTH}x${HEIGHT}]"
|
||||
media-ctl -d $mediadev --set-v4l2 "'$bridgesubdev':2[fmt:$sensorbuscode/${WIDTH}x${HEIGHT}]"
|
||||
print_debug media-ctl -d $mediadev --set-v4l2 "'$interfacesubdev':1[fmt:$parallelbuscode/${WIDTH}x${HEIGHT}]"
|
||||
media-ctl -d $mediadev --set-v4l2 "'$interfacesubdev':1[fmt:$parallelbuscode/${WIDTH}x${HEIGHT}]"
|
||||
print_debug media-ctl -d $mediadev --set-v4l2 "'dcmipp_dump_postproc':1[fmt:$parallelbuscode/${WIDTH}x${HEIGHT}]"
|
||||
media-ctl -d $mediadev --set-v4l2 "'dcmipp_dump_postproc':1[fmt:$parallelbuscode/${WIDTH}x${HEIGHT}]"
|
||||
V4L2_CAPS="video/x-raw, format=RGB16, width=$WIDTH, height=$HEIGHT"
|
||||
V4L_OPT=""
|
||||
|
||||
else
|
||||
is_dcmi_present
|
||||
if [ "$DCMI_SENSOR" != "NOTFOUND" ]; then
|
||||
COMPATIBLE_BOARD=$(cat /proc/device-tree/compatible | sed "s|st,|,|g" | cut -d ',' -f2)
|
||||
case $COMPATIBLE_BOARD in
|
||||
stm32mp15*)
|
||||
WIDTH=640
|
||||
HEIGHT=480
|
||||
;;
|
||||
*)
|
||||
WIDTH=640
|
||||
HEIGHT=480
|
||||
;;
|
||||
esac
|
||||
else
|
||||
get_webcam_device
|
||||
# suppose we have a webcam
|
||||
WIDTH=640
|
||||
HEIGHT=480
|
||||
fi
|
||||
|
||||
V4L2_CAPS="video/x-raw, width=$WIDTH, height=$HEIGHT"
|
||||
V4L_OPT="io-mode=4"
|
||||
v4l2-ctl --set-parm=30
|
||||
fi
|
||||
|
||||
|
||||
echo "Gstreamer graph:"
|
||||
GRAPH="v4l2src $V4L_DEVICE $V4L_OPT ! $V4L2_CAPS ! queue ! $ADDONS gtkwaylandsink name=gtkwsink"
|
||||
|
||||
echo " $GRAPH"
|
||||
pty_exec "$GRAPH"
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
#killall gst-launch-1.0
|
||||
killall touch-event-gtk-player
|
||||
Reference in New Issue
Block a user