Creating image from polar coordinates

asked 2020-04-05 09:14:55 -0500

Hi, I have readings from laser rangefinder from 0 to 356 degree with 1 degree step. I have to convert it to cartezian (this i can do) but i have to create martix (image) where when the obstacle is detected the value is 255 when not is 0 and i have to detect lines using iterate line detection. I have no clue how to use it and how to create this kind of matrix.

200.0 200.0304641 200.1219029 200.2744558 200.4883557 200.7639301 201.1016019 201.5018913 201.9654178 202.4929022 203.0851699 203.7431535 204.4678969 205.2605592 206.1224195 207.0548817 208.0594807 209.1378884 210.2919211 211.5235469 212.8348947 214.2282633 215.706132 217.2711722 218.9262595 220.6744883 222.5191864 224.4639325 226.5125741 228.6692482 230.9384043 233.3248287 235.8336725 238.4704823 241.2412337 244.1523697 247.210842 250.4241583 253.8004342 257.3484521 261.0777262 264.9985766 269.1222119 273.4608227 278.0276874 282.8372924 287.9054677 293.249543 298.8885247 304.8432998 311.1368702 317.7946226 324.8446419 332.3180748 340.2495541 305.1904621 301.5515421 298.0881028 294.7920906 291.6560358 288.6730054 285.8365603 283.1407176 280.5799156 278.1489831 275.8375563 273.6520894 271.5830538 269.6265812 215.7094724 214.2314152 212.8378638 211.5263385 210.29454 209.1403391 208.0617674 207.0570082 205.2623756 204.4695627 203.7446715 203.0865425 202.4941316 201.9665058 201.5028397 201.1024121 200.7646034 200.4888932 200.2748582 200.1221709 200.0305981 200.0000001 200.0303305 200.1216352 200.2740537 200.4878186 200.7632571 201.100792 201.5009433 201.9643301 202.4916732 203.0837976 203.7416358 204.4662314 205.2587432 206.12045 207.0527555 208.0571943 209.135438 210.2893026 211.5207557 212.831926 214.2251118 215.7027921 217.2676378 218.922524 220.6705447 222.5150272 224.4595494 226.5079584 228.6643906 230.9332945 233.3194559 235.8280249 238.4645473 241.2349977 244.145818 247.2039587 250.4169263 253.792835 257.3404656 261.0693307 264.9897485 269.1129254 273.45105 278.0173981 282.8264532 417.0724044 410.220557 403.7111818 397.5243538 391.64178 386.0466415 380.7234526 375.6579368 370.8369161 366.2482128 361.8805615 357.7235312 353.7674542 350.0033641 346.4229383 343.0184477 339.7827104 336.7090502 333.7912596 331.0235652 328.4005977 325.9173635 323.5692197 321.3518513 319.2612501 317.2936957 315.4457389 313.7141853 312.0960816 310.5887025 309.1895392 307.8962884 306.7068433 305.6192847 304.6318731 303.7430418 302.9513912 302.2556826 301.654834 301.1479156 300.7341464 300.4128914 300.1836588 300.0460985

edit retag flag offensive close merge delete

Comments

from 0 to 356 degree with 1 degree step

clockwise ?

i only see 180 numbers here (did you truncate it ?) which could be z values (distance ? find out please)

you could draw a curve into an image, maybe using a vector<Point(x,y)> in cart. coords and filled polyLines()

berak gravatar imageberak ( 2020-04-05 09:59:26 -0500 )edit

sorry my mistake - they are from 0 to 179 and there is no z value when the laser hit the obstacle there should be 255 value in matrix (i do not know more)

Ceranthor gravatar imageCeranthor ( 2020-04-05 10:26:23 -0500 )edit

i do not know more

please try to find out.

when the laser hit the obstacle there should be 255 value in matrix

look at it, no 255 in the data, it seems distributed between 200 and 417

berak gravatar imageberak ( 2020-04-05 10:29:50 -0500 )edit

The r.txt file contains readings from the laser rangefinder. These are obstacle distances for subsequent scan angles from 0 to 179, every one degree. You should: save data in Cartesian coordinates, detect lines iterative segment detection method. create an image (table) in which the coordinates are saved for obstacles detected. Cell (i, j) has the value 255 if in (i, j) is obstacle detected and 0 otherwise. detect lines using the Hough transform method

This is what i have to do (I had 0 lessons about OpenCv in pascal :) )

Ceranthor gravatar imageCeranthor ( 2020-04-05 10:40:09 -0500 )edit

I do not know how close is obstacle i just have to do it and cry :)

Ceranthor gravatar imageCeranthor ( 2020-04-05 10:44:01 -0500 )edit

once you have cartesian coords, you can plot them.

and since they're consecutive you do not need to detect lines, just connect the dots.

image description

berak gravatar imageberak ( 2020-04-06 06:19:27 -0500 )edit

can you paste the code for this please?

Ceranthor gravatar imageCeranthor ( 2020-04-06 06:38:02 -0500 )edit

no, it's an assignment, right ?

try something first and show us, please.

break it down:

  • read data
  • polarToCart()
  • plot.
berak gravatar imageberak ( 2020-04-06 06:48:17 -0500 )edit