Opencv laser line recognition

I want to detect a laser line for an autonomous system.

My work so far: 1. I have divided the image in the rgb channels 2. use only the red channel due to the use of the red laser line 3. Get the threshold value manually 4. Search for the binary image for the value! = 0

I can’t install it manually for use in the automated system of any ideas how to solve the problem?

And only the search for the highest peak in the image is not good enough due to the fall of sunlight.

Perhaps I can find short peaks .. Because in the area of ​​the laser line, the brightness increases rapidly, and then quickly decreases after the laser line.

How can I understand that in opencv?

Image with laser

manual treshholded image

with an object

+4
source share
1 answer

, . .

  • ( )

  • ,

1 - ( )

- , - , , . -auto-level, 0-255 95%, , 5% . (#ffffff). ImageMagick, :

convert http://i.stack.imgur.com/1P1zj.jpg -colorspace gray \
    -resize x1!                                             \
    -auto-level                                             \
    -threshold 95% text: | grep -i ffffff

:

297,0: (255,255,255)  #FFFFFF  white
298,0: (255,255,255)  #FFFFFF  white
299,0: (255,255,255)  #FFFFFF  white

, , 297-299 - , . , , . , , , , , , .

1, 2 .

1 :

convert input.png -crop 1x +repage line%d.png

( ) :

for f in line*; do m=$(convert -format "%[fx:mean]" $f info:);echo $m:$f ;done | sort -g

...
...
0.559298:line180.png
0.561051:line185.png
0.561337:line306.png
0.562527:line184.png
0.562939:line183.png
0.584523:line295.png
0.590632:line299.png
0.644543:line296.png
0.671116:line298.png
0.71122:line297.png      <--- brightest column = 297

2 -

297 , , , .

convert line297.png -colorspace gray -auto-level -threshold 20% -negate txt:

...
0,100: (0,0,0)  #000000  black
0,101: (0,0,0)  #000000  black
0,102: (0,0,0)  #000000  black
0,103: (0,0,0)  #000000  black
0,104: (0,0,0)  #000000  black
0,105: (0,0,0)  #000000  black
0,106: (0,0,0)  #000000  black
0,107: (0,0,0)  #000000  black
0,108: (255,255,255)  #FFFFFF  white  <- gap in laser line
0,109: (255,255,255)  #FFFFFF  white  <- gap in laser line
0,110: (255,255,255)  #FFFFFF  white  <- gap in laser line
0,111: (255,255,255)  #FFFFFF  white  <- gap in laser line
0,112: (0,0,0)  #000000  black
0,113: (0,0,0)  #000000  black
...
0,478: (0,0,0)  #000000  black
0,479: (0,0,0)  #000000  black

3 - , ​​

, , , , , , 297.

, 240 340, , :

for i in {240..340} ;do n=$(convert line${i}.png mask.png -compose multiply -composite -format "%[mean]" info:);echo $n:$i ;done | sort -g

:

458.495:248
466.169:249
468.668:247
498.294:260
502.756:250
536.844:259
557.726:258
564.508:251
624.117:252
627.508:253  <--- column 253 is brightest

, 253 , . , 253.

, opencv.

, , opencv, ImageMagick. , 1 , . . , :

Split image into single pixel columns
convert http://i.stack.imgur.com/vMiU1.jpg -crop 1x +repage line%04d.png

, :

ls line*
line0000.png    line0128.png    line0256.png    line0384.png    line0512.png
line0001.png    line0129.png    line0257.png    line0385.png    line0513.png
...
line0126.png    line0254.png    line0382.png    line0510.png    line0638.png
line0127.png    line0255.png    line0383.png    line0511.png    line0639.png

, 640 . ...

identify line0639.png 
line0639.png PNG 1x480 1x480+0+0 8-bit sRGB 1.33KB 0.000u 0:00.000

, 1 480 .

:

for f in line*; do m=$(convert -format "%[fx:mean]" $f info:);echo $m:$f ;done | sort -g

0.5151:line0103.png
0.521621:line0104.png
0.527829:line0360.png
0.54699:line0356.png
0.567822:line0355.png
0.752827:line0358.png  <--- highest brightness
0.76616:line0357.png   <--- highest brightness

357 358 .

+1

Source: https://habr.com/ru/post/1570276/


All Articles