# ROS座標轉Image畫圖點位記錄 ## ROS座標資訊 image: t213res2.pgm resolution: 0.020000 origin: [-60.880000, -89.680000, 0.000000] negate: 0 occupied_thresh: 0.65 free_thresh: 0.196 位置: (-60.88, -89.68) Resolution:0.02 表圖 1 pixel = 0.02m --- ## Step1 根據位置(-60.88, -89.68)找出原點(0,0) -60.88 + 0.02 X = 0 -89.68 + 0.02 y = 0 算出 X=3044, y=4484 3044,4484 在小畫家(Y軸由下往上)位置大約如下圖 ![](https://i.imgur.com/Avgs3pB.png) 但這不是實際位置,還需轉成img坐標系(Y軸由上往下) ## Step2 (3044, 4484) 實際Img位置 ![](https://i.imgur.com/BMfgGTj.png) 實際Img Piel位置為(3044,3004) ## Step3 向右旋轉90度. 座標轉換 實際Web圖為橫式,圖片須向右選轉90度。得知旋轉角度為(x',y'),原座標為(x,y) x'=xcos(90)+ysin(90); y'=ycos(90)-xsin(90); x' = 3044*cos(90)+3004*sin(90) = 3004 y' = 3004*cos(90)-3044*sin(90) = -3044 Img無坐標系無負值全部取絕對值 Web圖實際座標為(3004, 3044) ## Step4 切圖 若切圖點pixel座標為 (1000, 1000) 實際座標則須扣除 切點座標值 (3004-1000, 3044-1000) = (2004, 2044) Ref:https://www.itread01.com/content/1548126931.html