Steuerung von canon eos über Computer mit Einblenden eines Maßstabs

Begonnen von micromax, Juni 30, 2019, 21:06:48 NACHMITTAGS

Vorheriges Thema - Nächstes Thema

Florian D.

Hallo Thomas,

jetzt hatte ich wenigstens selber mal einen Anreiz, mich mit dieser Thematik zu beschäftigen. Ich verwende darktable, weil es das EOS utility für Linux leider nicht gibt. Dort gebe ich als exif Kommentar z. B. "10x" ein. Das Bash Skript von Archäometallurgie habe ich angepasst. Dort habe ich (bis jetzt) die Bildbreite in mum für die Vergrösserungen 3.5, 10, 25 und 50 hinterlegt, die ich mit dem Objektmikrometer ausgelesen habe.  Damit das Skript funktioniert, musste ich exiftool und imagemagick installieren. Das Skript selber habe ich in .alias hinterlegt, so dass es von Überall aufgerufen werden kann. Ruft man das Skript auf, so wird ein Unterordner "annotate" angelegt und dort für alle *.jpg Bilder im Originalordner Kopien abgelegt, die den Massbalken und einen Text enthalten. Das sieht dann so aus, wie im Anhang.
Hier das Skript, wie es momentan aussieht. Es sollte ein Leichtes sein, für Windows ein analoges batch script zu schreiben.

#!/bin/bash

ext='jpg'
colour='white'
bgcolour='black'
inform='Florian D.'
for f in *.$ext
do
label=`exiftool -description ${f}|sed " s/.*[[:blank:]]\([0-9]\+[.]*[0-9]*\)x/\1/"`
echo $label
if (( `echo "$label == 50" | bc`  ))
then section=175
fi
if (( `echo "$label == 25" | bc` ))
then section=350
fi
if (( `echo "$label == 10" | bc` ))
then section=860
fi
if (( `echo "$label == 3.5" | bc` ))
then section=2.250
fi
echo $section
if ((`echo $section \> 70 | bc` & `echo $section \< 149 | bc`))
then
legende=25
unit='µm'
elif ((`echo $section  \> 150 | bc` & `echo $section  \< 499 | bc`))
then
legende=50
unit='µm'
elif ((`echo $section  \>= 500 | bc` & `echo $section  \< 999 | bc`))
then
legende=100
unit='µm'
elif ((`echo $section  \>= 1000 | bc` & `echo $section  \< 2000 | bc`))
then
legende=200
unit='µm'
elif ((`echo $section  \> 0.8 | bc` & `echo $section  \< 2.0 | bc`))
then
legende=`echo 0.2 | bc`
unit='mm'
elif ((`echo $section  \>= 2.0 | bc` & `echo $section  \< 4.0 | bc`))
then
legende=1
unit='mm'
elif ((`echo $section  \>= 4.0 | bc` & `echo $section  \< 6.0 | bc`))
then
unit='mm'
fi
width=`identify -format %w ${f}`    # %w is the width in pixels
height=`identify -format %h ${f}`     # %h is the height in pixels
bh=$(( ($height/24)))            # bh is the boxheight

# always use the longest side of the
# micrograph for the calculation of the scalebar!

if (( $width > $height ))        # landscape
then
scalebar=$((`echo $width\*$legende\/$section\+$bh | bc`))
strokewidth=$((`echo $width\*$legende\/$section\/50 | bc`))
#strokewidth=$(( $width*$legende/$section/50 ))
textpox=$((`echo $width\*$legende\/$section\/2 | bc`))

elif (( $height > $width ))        # portrait
then
scalebar=$((`echo $height\*$legende\/$section\+$bh | bc`))
#strokewidth=$(( $width*$legende/$section/50 ))
strokewidth=$((`echo $width\*$legende\/$section\/50 | bc`))
textpox=$((`echo $height\*$legende\/$section\/2 | bc`))
fi

rh=$(( $height/40 ))            #rh is the pointsize
uy=$(( $height+$bh/4 ))            #uy: upper y position of the box
textpoy=$(( $height-(($bh-$rh)*8/10) ))

if [ ! -d "annotated" ]; then        #check if the folder does exist
   mkdir annotated
fi

echo annotated ${f} and saved a copy to annotated/${f}


convert ${f} -gravity South -background 'black' -splice 0x${bh} -stroke ${colour} \
-strokewidth ${strokewidth} -draw "line ${bh},${uy},${scalebar},${uy}" \
-gravity SouthWest -pointsize ${rh} -fill ${colour} -strokewidth 0  -draw "translate   $textpox,0 text 0,0 '${legende} ${unit}'" \
-gravity SouthEast -pointsize ${rh} -fill ${colour} -strokewidth 0  -draw "translate   ${bh},0 text 0,0 '${inform}" annotated/${f}
done

Viele Grüsse
Florian







Florian D.

Ups, sehe gerade, dass ich ja gar nicht das Bild mit Masstab hochgeladen habe!
Hier ist es.