I am getting just an white image, so I looked up the commands for imagemagick and added -channel played with the threshold and now I am getting some black in the images.
Code:
FS_BRIGHT=34
FS_CONT=17
THRESH=12
dname=webcam-shot.png
fswebcam --quiet -d v4l2:/dev/video0 --no-banner \
-F 15 -S 15 -D 1 -p YUYV --png 9 $dname \
-s brightness=${FS_BRIGHT}% -s contrast=${FS_CONT} - | \
convert - -rotate $ROTATE -channel red -threshold ${THRESH}% \
-colorspace gray -background white \
-alpha remove -alpha off +dither -posterize 2 -flatten - |
tee \
>( cat > $dname ) \
>( convert - -crop $TTE tte.png ) \
>( convert - -crop $TRH trh.png ) \
>( convert - -crop $ETE ete.png ) \
>( convert - -crop $ERH erh.png ) \
> /dev/null
running just this
Code:
#!/bin/bash
set -x
ROTATE=-1.57
TTE=68x64+147+58
TRH=56x50+150+127
ETE=44x46+117+206
ERH=46x45+193+207
FS_BRIGHT=34
FS_CONT=17
THRESH=12
dname=webcam-shot.png
fswebcam --quiet -d v4l2:/dev/video0 --no-banner \
-F 15 -S 15 -D 1 -p YUYV --png 9 $dname \
-s brightness=${FS_BRIGHT}% -s contrast=${FS_CONT} - | \
convert - -rotate $ROTATE -channel red -threshold ${THRESH}% $dname
I can actually see me from my laptop webcam with the red channel having been manipulated.
using that threshold maybe forgetting to pick the channel red,green,blue leaves it whatever it leaves it then with no real bases to work with when you add your black and white -- basically white maybe the only thing it has to work with.
I am not versed in image manipulations.
but if you are going to just turn it back and white in the end then what are you doing messing with the threshold for? it seems redundant to me.
removing all of the colors then calling to have it posterized on a black and white image.
I have not tested all the way down to that, but it still seems if one has a black and white image then how is one suspect to get reds and greens and blues out of it to be posterized?
Code:
-posterize levels
reduce the image to a limited number of color levels per channel.
Very low values of levels, e.g., 2, 3, 4, have the most visible effect.
it has nothing to work with, but as I said, I am not versed in image manipulations. So i might be talking out my butt.
MOD:
messing with it still, if you use the code I tore down in the second code posted then add -posterize 2 to the last line, and change the name of the image so I can compare them. I see a definite difference between the two images.
Code:
convert - -rotate $ROTATE -channel red -threshold ${THRESH}% -posterize 2 $dname
this will give you an actual image you can make out, and I changed it to resize, cropping only gives you a little peice of the image, leaving it unreconziable to what it was.
Code:
#!/bin/bash
set -x
ROTATE=-1.57
TTE=68x64+147+58
TRH=56x50+150+127
ETE=44x46+117+206
ERH=46x45+193+207
FS_BRIGHT=34
FS_CONT=17
THRESH=3
dname=webcam-shot.png
fswebcam --quiet -d v4l2:/dev/video0 --no-banner \
-F 15 -S 15 -D 1 -p YUYV --png 9 \
-s brightness=${FS_BRIGHT}% -s contrast=${FS_CONT} - |
convert - -rotate $ROTATE -channel red -threshold ${THRESH}% \
-posterize 2 - | \
tee \
>( cat > $dname ) \
>( convert - -resize $TTE tte.png ) \
>( convert - -resize $TRH trh.png ) \
>( convert - -resize $ETE ete.png ) \
>( convert - -resize $ERH erh.png ) \
> /dev/null
for i in {0..10}; do
[[ -s tte.png && -s trh.png && -s ete.png && -s erh.png ]] && break
sleep 0.33
done
#for i in tte trh ete erh; do
# ssocr -C -c digits -d -1 -T $i.png || echo "bad value"
#done
I commented out the last one because I have no idea what that is doing, ssocr, I do not even have installed, as well.