> For the complete documentation index, see [llms.txt](https://gmii.gitbook.io/gmii-tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gmii.gitbook.io/gmii-tw/gmii-vision/coordinate.md).

# 裝置座標轉換

## 裝置參考座標系

每個裝置都有相對的參考座標系，在個別的輸入或輸出上皆須使用各自的參考座標系，例如：

* 視覺檢測取得的座標為相機的參考座標系的資料
* 機械手臂在控制移至定點時使用的座標為本身的參考座標系的座標。

## 校正

{% file src="/files/-M5zz28P\_f9OWUzKDN6d" %}
校正卡
{% endfile %}

在校正相機與機械手臂之前，先將校正卡列印出來。對一台相機與一台機械手臂之參考座標系校正。校正方法的順序如下：

1. 將校正卡放置於相機可拍攝到的區域以及機械手臂的工作區域內。
2. 擷取指定編號之相機影像上的校正卡，會檢測到校正卡的四個角落交叉點之位置（下圖紅點處）。
3. 將機械手臂移至校正卡上指定的四個點位（下圖紅點處）並分別記錄位置。
4. 將機械手臂移置其末端工具碰到校正卡，紀錄高度。
5. 執行校正計算。

![](/files/-M2r7aF1qLgxlx5eYUw3)

## 在任務中轉換座標系

註：相機是2D平面座標系，目標檢測之結果為2D資訊，在轉換至機械手臂的座標時，需加入目標物件的高度。

### Blockly API

![](/files/-M2r7aF2b-4eYVUGxkA5)

### Python API

```
GmiiVisionAPI.TargetPositionToDobotMagicianCoordinate(GmiiVisionSocket, 0, 0, [0, 0, 0, 0], 0) # 相機編號, Magician編號, 相機座標系的座標, 高度
GmiiVisionAPI.TargetPositionToDobotM1Coordinate(GmiiVisionSocket, 0, 0, [0, 0, 0, 0], 0) # 相機編號, Magician編號, 相機座標系的座標, 高度
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gmii.gitbook.io/gmii-tw/gmii-vision/coordinate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
