Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 5103  / 1 Year ago, fri, december 16, 2022, 3:05:52

I created a .sh script for simple OCR-ing of screenshots that I make with Shutter.
The script looks like this (ocrFile.sh):



#!/bin/bash

convert $1 /tmp/output.pnm
cat /tmp/output.pnm | pamstretch 4 > /tmp/stretched.pnm
convert /tmp/stretched.pnm -colorspace gray /tmp/output600dpi.tif
tesseract /tmp/output600dpi.tif ./outputText -l eng


This script does some image enhancing that is required when OCRing with tesseract.
It does the job properly if it is called from the terminal. What I wanted was to do the whole process within Nemo, so I created a custom action named OCR.nemo_action inside /home/user1/.local/share/nemo/actions with the following content:



[Nemo Action]
Name=OCR The Screenshoot
Comment=OCR Function for Nemo File Manager
Exec=<ocrFile.sh %F>
Icon-Name=gtk-execute
Selection=Any
Extensions=png;


This Nemo action don't produce output with the script given above.
The .sh script is also in the folder for Nemo's custom actions.



Please help!


More From » bash

 Answers
4

Great!!



-- ~/OCR.sh ( chmod +x ~/OCR.sh )



#!/bin/bash
convert $1 /tmp/OCR-output.pnm
cat /tmp/OCR-output.pnm | pamstretch 4 > /tmp/OCR-stretched.pnm
convert /tmp/OCR-stretched.pnm -colorspace gray /tmp/OCR-output600dpi.tif
tesseract /tmp/OCR-output600dpi.tif ~/Desktop/OCR-outputText -l eng
rm /tmp/OCR-output.pnm /tmp/OCR-stretched.pnm /tmp/OCR-output600dpi.tif





-- ~/.local/share/nemo/actions



[Nemo Action]
Active=true
Name=OCR picture
Comment=OCR Function for Nemo File Manager
Selection=S
Exec=/bin/bash /home/user/OCR.sh %F --- change "user"
Icon-Name=gtk-execute
Extensions=png;jpg;jpeg;bmp;





And OCR text is on my Desktop !!!


[#27059] Saturday, December 17, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lawain

Total Points: 150
Total Questions: 106
Total Answers: 101

Location: China
Member since Mon, Aug 22, 2022
2 Years ago
lawain questions
;