Skip to content

getting ros nxt out of the closet

 

https://github.com/NXT-ROS/nxt

This package isn’t installed by default

sudo apt-get install python-nxt

make sure quotes are there. should probably just be 660, i changed it while i was having issues

cat /etc/udev/rules.d/70-lego.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="0694", GROUP="lego", MODE="0666"

reading from the sensor

rostopic echo my_touch_sensor

moving the motor

rostopic pub -1 joint_command nxt_msgs/JointCommand -- motor_joint 0.9

To use the base nxt packages with the nxt_robots package you will need to chain together the catkin workspaces

https://github.com/NXT-ROS/nxt_robots

 

Induction heating to remove seized bolt

Working on replacing the timing chain gasket on my 99 ford explorer 5.0

got to the point of some seized bolts and not sure what to do.

using a big blow torch sounds like it would work best but I don’t have one and I don’t want to strip my motor down enough to do it safety.

After a while I remembered inductive heating. Fortunatly there is a tool for that! Unfortunatly it is like $500. But it works really well!

After some more thinking I decided to go more of the DIY route and bought this for $13.
https://www.amazon.com/gp/product/B01GDVVANA/

I needed a power supply so I grabbed an old PC power supply. Using some yellow 12 volt wires and the black ground wires. Needed to add a power button by bridgeing the green and black wires on the 20 pin connector
* http://www.tomshardware.com/forum/198025-28-turning-power-supply
* http://case-mods.linear1.org/case-mod-101-the-atx-power-switch-demystified/

Yay it heats up a paper clip to red hot in about 8 seconds!

I needed some sort of project case to use in the actual repair!

The bolt I needed to heat up was larger then a paperclip so it took longer to heat up. Doing a bench test after about 2 minutes I was able to get the bolt to about 600 degrees!

In the end I couldn’t generate enough heat when the bolt was in the block using the $13 inductive heating unit. A $55 handheld torch did the job.

Gasket replaced!

after fixing dpi what else can you do?

fix DPI (if needed) 300 DPI is minimum
fix text size (e.g. 12 pt should be ok)
try to fix text lines (deskew and dewarp text)
try to fix illumination of image (e.g. no dark part of image
binarize and de-noise image

http://stackoverflow.com/questions/9480013/image-processing-to-improve-tesseract-ocr-accuracy
http://en.wikipedia.org/wiki/Image_scaling

User Scenario: Process digital camera pictures and OCR to extract specific numbers


https://mazira.com/blog/optimal-image-conversion-settings-tesseract-ocr

DPI and you?

I have been experimenting with tasseract and occasionally get really terrible results when I know I should not. When I grab the images, change the dpi aka save them at a different resolution I get great results.

Tasseract wants 300 dpi. when I google dpi of digital images or how to change dpi on android most of the information is along the lines of “you dont want dpi, you dont know what you are talking about, your life is a lie and nobody cares about you”. So what is going on here?

Maybe some more details from Tasseract will help:

Is there a Minimum Text Size? (It won’t read screen text!)
There is a minimum text size for reasonable accuracy. You have to consider resolution as well as point size. Accuracy drops off below 10pt x 300dpi, rapidly below 8pt x 300dpi. A quick check is to count the pixels of the x-height of your characters. (X-height is the height of the lower case x.) At 10pt x 300dpi x-heights are typically about 20 pixels, although this can vary dramatically from font to font. Below an x-height of 10 pixels, you have very little chance of accurate results, and below about 8 pixels, most of the text will be “noise removed”.

So it looks like they want the letters to be within a certain range of pixels tall. They only give minimum pixels here, around 20 pixels minimum. But I believe there is also a maximum pixel height they will look for. In my previous post ‘tesseract’ small unclear text was picked up reliably but large very clear text was ignored. From what I can find on google it does not appear there is a configured maximum but a algorithm that tries to determine it based on picture height.

My current image is 115 x 59 and the text is about 1/3 of that height or about 19 to 20 pixels high. It seems silly to my that doubling the pixels in the picture with no quality improvement would yield better results but I guess I can give it a try.

So my next steps will be

  1. Make sure my text is above the minimum pixel xheight by a safe margin
  2. study up more on the max height algorithm. maybe I just need to zoom out?

building AnySoftKeyboard

Trying to build anysoftkeyboard

https://github.com/AnySoftKeyboard/AnySoftKeyboard/wiki/How-to-Build-AnySoftKeyboard/8d1a075333ff9a649f237aba35b0a4da74821d81

android update project -p .
Error: . is not a valid project (AndroidManifest.xml not found).

cool, the android manifest is actually a couple directories deep. ill skip this for now

next step


gradle build
:buildSrc:clean
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ‘:compileGroovy’.
Cause: You must assign a Groovy library to the groovy configuration!

* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.

BUILD FAILED

Total time: 2.374 secs

well that went well. Probably because I have a super old version of gradle by default with ubuntu that doesnt include the groovy configs by default.

Installing the latest and greatest gradle fixed it. Overall I enjoy apt-get but this seems to be a recurring problem!

arduino keyboard wedge

source for example keyboard
https://android.googlesource.com/platform/development/+/master/samples/SoftKeyboard

Had to fix preferenceActivity by adding is valid fragment true
http://stackoverflow.com/questions/19973034/isvalidfragment-android-api-19

git clone of softkeybaord
http://stackoverflow.com/questions/14171639/softkeyboard-questions

android google repos
https://android.googlesource.com/

http://stackoverflow.com/questions/16060579/how-to-draw-view-on-top-of-soft-keyboard-like-whatsapp
http://stackoverflow.com/questions/26659275/android-add-view-above-keyboard-key-and-below-feedback-popup-for-key
http://www.fampennings.nl/maarten/android/09keyboard/index.htm
http://developer.android.com/reference/android/inputmethodservice/KeyboardView.html
http://developer.android.com/reference/android/view/View.html
http://developer.android.com/guide/topics/text/creating-input-method.html

this looks pretty spot on to what i want to do
https://sites.google.com/site/intuitit/support/intuitit-ime

going to base off new keyboard
https://github.com/AnySoftKeyboard/AnySoftKeyboard

Zoom in android app

https://code.google.com/p/eyes-free/source/browse/trunk/archived/magnify/?r=760#magnify%2Fsrc%2Fcom%2Fgoogle%2Fmarvin%2Fmagnify

http://stackoverflow.com/questions/6503106/add-zoom-controls-of-camera-in-camera

http://developer.android.com/training/camera/cameradirect.html

trying out (another) android-ocr app

After getting my feet wet with the simple app in my last post I wanted to try a little bit more advanced app.

Getting it running was pretty straight forward.

  1. git clone https://github.com/rmtheis/android-ocr.git android-ocr
  2. made sure it was pointing at tess two
  3. right clicked on project and ran as android app

android_ocr_Screenshot

it works pretty well. thoughts

  • I dont need the translation stuff so I will rip that out.
  • zoom would be nice for when you are a little farther away
  • there is some code for continuous recognition, that sounds neat but im not sure how to enable it
  • it would be nice to prompt the user if this is correct, save the files

Starting out with Simple-Android-OCR on ubuntu

pretty boring post. basically followed this tutorial

  1. make sure you have the build toolssudo apt-get install build-essential
    sudo apt-get install ia32-libs
    sudo apt-get update
    sudo apt-get install ia32-libs
    sudo apt-get install openjdk-6-jdk
    sudo apt-get install icedtea-plugin
  2. install android sdk
  3. install android ndk
  4. add adt tools to your path and .bashrc
  5. build tess-two
    git clone git://github.com/rmtheis/tess-two tess
    cd tess/tess-two
    ndk-build
    fix target in project.properties
    android update project –path .
    ant release
  6. build eyes-two
    cd ../eyes-two/
    ndk-build
    fix target in project.properties
    android update project –path .
    ant release
  7. build simple-android ocr
    git clone https://github.com/GautamGupta/Simple-Android-OCR.git Simple-Android-OCR
    go change target version in properties file
    point the project at the tess two install path
  8. I had trouble getting my phone to allow the debug connection. “adb devices” would either return nothing or the device serial number as question marks or the status as unauthorized. I tried several combinations of restarting adb along with restarting the phone, unplugging and replugging, disabling / enabling dev mode. I think is what finally did it was removing all currently authorised computers from my phone.ANDROID_SDK_HOME=~/adt-bundle-linux-x86-20140702/sdk
    export ANDROID_SDK_HOME
    and add to .bashrc
    2015 adb kill-server
    2016 adb start-server
    2017 adb devices
  9. open eclipse, right click on simple ocr project and run as android application.
  10. success!
    dev

tesseract

Tesseract is probably the most accurate open source OCR engine available. It differs from OpenCV because opencv is a general purpose image library. You could use it to build something like Teseeract.

How well does it work? I downloaded the latest portable version to try it out. The ReadMe is very helpful.

IMG_43111

out of the box

Out of the box just point it at an image.


>tesseract.exe IMG.JPG out
>cat out.txt
*1
*3
'?
i

v

.‘-go.-—: qv..»- . v_—
r : -.; 1

‘LT WT

Lp LMT 223500
62500

_ ‘ -r~,.\’4-5-p-—-A-. 4.
ts‘ “3′ ”’

2 INCH HF COMP SHOES

..,. …¢…-..

,, ..–4
..r…..

Pretty impressive that it correctly read the small text at the bottom but pretty said it missed the giant text in the middle.

focus on digits

Maybe if I focus on digits I can get the big “352264”.

In Tesseract-OCR\
>cat tessdata\configs\digits
tessedit_char_whitelist 0123456789
>tesseract.exe IMG_4311.JPG out digits
>cat out.txt
21
23
3
0

0

20522024 0101022 2 222
1 2 252 0

17 0011

00 1001 223500
02500

2 0 0554112402 42
2200 11 000

2 10168 512 60009 551053

2402 0242402

202 0224
2222232

So my guess is the letters are too big compared to the size of the picture. Tesseract is really geared towards looking at a page of text so it would make sense to ignore larger patterns and focus on smaller ones.

general approach for best results from tasseract

according to this stack overflow post

  1. fix DPI (if needed) 300 DPI is minimum
  2. fix text size (e.g. 12 pt should be ok)
  3. try to fix text lines (deskew and dewarp text)
  4. try to fix illumination of image (e.g. no dark part of image
  5. binarize and de-noise image

fix DPI

The original dpi of the image was 72. Probably a setting in the camera that could be changed, or changed automatically with pre processing.

As a quick test I changed the dpi in gimp to the recommended 300.


>tesseract.exe 300dpi.JPG out
>cat out.txt

_`__ ___`___,.. ….-u-9.`-“”

._ , ,~…,.–… ….

..- …-..-…….

..,\.-.,~. –
,, .. ….~\-.»..v
, ., ._..x-. o-

CHTT mi
«~352264

«:4.»

`$7

a
I
.

`a
n

V.`-w-v -2
..
”’-_§_“’.: ‘. `

QLD LMT 223500
`L1 WT 62500

co.
..
_ . ‘ “.”..”4-1`
.:…–“!CT::~ ts`

2 INCH HF COMP SHOES

Success! I got the string CHTT 352264 I was looking for. But there is still a bunch of junk..

only allow alpha numeric

In Tesseract-OCR\
>cat tessdata\configs\alphanumeric
tessedit_char_whitelist 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
>tesseract.exe IMG_4311.JPG out alphanumeric
>cat out.txt

V1 HFR4 9P

A 4 N NW

H 4 N

V A
H A V
F N

CHTT M
U352264

V4

37

I
1

V

V 4

V1 2

3 LD LMT 223500
LT WT 62500

A
P P 41
A IQ17 M

2 INCH HF COMP SHOES

what is next?

  • use regex to limit the pattern I want
  • pre-process the image more, possibly only look at largest text

links