杨楠77 2023-11-22 16:14 采纳率: 0%
浏览 35
已结题

无人机影像像素坐标转世界坐标

我有几组无人机影像数据及处理后的xml信息,我希望通过yolov5目标检测检测出感兴趣的物体后,根据检测框的像素坐标计算出其实际的世界坐标

<?xml version="1.0" encoding="utf-8"?>
<BlocksExchange version="3.2">
    <SpatialReferenceSystems>
        <SRS>
            <Id>1</Id>
            <Name>EPSG:4978</Name>
            <Definition>EPSG:4978</Definition>
        </SRS>
        <SRS>
            <Id>2</Id>
            <Name>EPSG:4326+5773</Name>
            <Definition>EPSG:4326+5773</Definition>
        </SRS>
        <SRS>
            <Id>3</Id>
            <Name>EPSG:4326</Name>
            <Definition>EPSG:4326</Definition>
        </SRS>
    </SpatialReferenceSystems>
    <Block>
        <Name>空三任务_1_clone_clone</Name>
        <Description>Export by Smart3D(soarscape.com) Version:5.0,build221102 64bit</Description>
        <SRSId>1</SRSId>
        <Photogroups>
            <Photogroup>
                <Name>南湾-1-f1</Name>
                <ImageDimensions>
                    <Width>6000</Width>
                    <Height>4000</Height>
                </ImageDimensions>
                <CameraModelType>Perspective</CameraModelType>
                <CameraModelBand>Visible</CameraModelBand>
                <FocalLength>35.60753779528072</FocalLength>
                <SensorSize>23.5</SensorSize>
                <PrincipalPoint>
                    <x>3049.4173703184692</x>
                    <y>2042.5520608621518</y>
                </PrincipalPoint>
                <CameraOrientation>XRightYDown</CameraOrientation>
                <Distortion>
                    <K1>-0.0084246744469627967</K1>
                    <K2>-0.045179449479387186</K2>
                    <K3>-0.017715008143209181</K3>
                    <P1>-0.00070299007778345222</P1>
                    <P2>-0.00059448390028627818</P2>
                </Distortion>
                <AspectRatio>1</AspectRatio>
                <Skew>0</Skew>
                <Photo>
                    <Id>0</Id>
                    <ImagePath>//10.0.0.220/Data1/00-photo/20220725-原平/南湾/1/f1/NW1010001.JPG</ImagePath>
                    <Component>1</Component>
                    <NearDepth>91.667172112607659</NearDepth>
                    <MedianDepth>171.56299059765448</MedianDepth>
                    <FarDepth>226.04661795383569</FarDepth>
                    <Pose>
                        <Rotation>
                            <M_00>0.95253883925056881</M_00>
                            <M_01>0.026702735566470508</M_01>
                            <M_02>0.30324367039139682</M_02>
                            <M_10>0.018261558780604592</M_10>
                            <M_11>-0.99936369954641679</M_11>
                            <M_12>0.030638399106377879</M_12>
                            <M_20>0.30386884537589814</M_20>
                            <M_21>-0.023646563009586074</M_21>
                            <M_22>-0.95242037193024809</M_22>
                        </Rotation>
                        <Center>
                            <x>-1966104.8823895147</x>
                            <y>4588592.6862530271</y>
                            <z>3957960.9511104464</z>
                        </Center>
                        <Metadata>
                            <SRSId>3</SRSId>
                            <Center>
                                <x>113.1940037</x>
                                <y>38.596605070000003</y>
                                <z>873.36429999999996</z>
                            </Center>
                        </Metadata>
                    </Pose>
                    <ExifData>
                        <ImageDimensions>
                            <x>6000</x>
                            <y>4000</y>
                        </ImageDimensions>
                        <Make>SONY</Make>
                        <Model>ILCE-6000</Model>
                    </ExifData>
                </Photo>
                <Photo>
                    <Id>1</Id>
                    <ImagePath>//10.0.0.220/Data1/00-photo/20220725-原平/南湾/1/f1/NW1010002.JPG</ImagePath>
                    <Component>1</Component>
                    <NearDepth>96.722267128997188</NearDepth>
                    <MedianDepth>173.96518099594235</MedianDepth>
                    <FarDepth>225.5660749861475</FarDepth>
                    <Pose>
                        <Rotation>
                            <M_00>0.91860609887032008</M_00>
                            <M_01>0.146017598659442</M_01>
                            <M_02>0.36720797376960929</M_02>
                            <M_10>0.12950475429318983</M_10>
                            <M_11>-0.98915001091954013</M_11>
                            <M_12>0.069359747067980371</M_12>
                            <M_20>0.37335151497444402</M_20>
                            <M_21>-0.016159108255216218</M_21>
                            <M_22>-0.92754920596520574</M_22>
                        </Rotation>
                        <Center>
                            <x>-1966125.0331433073</x>
                            <y>4588592.8072263049</y>
                            <z>3957954.4623308214</z>
                        </Center>
                        <Metadata>
                            <SRSId>3</SRSId>
                            <Center>
                                <x>113.1942138</x>
                                <y>38.596515230000001</y>
                                <z>875.53899999999999</z>
                            </Center>
                        </Metadata>
                    </Pose>
                    <ExifData>
                        <ImageDimensions>
                            <x>6000</x>
                            <y>4000</y>
                        </ImageDimensions>
                        <Make>SONY</Make>
                        <Model>ILCE-6000</Model>
                    </ExifData>
                </Photo>
                <Photo>
                    <Id>2</Id>
                    <ImagePath>//10.0.0.220/Data1/00-photo/20220725-原平/南湾/1/f1/NW1010003.JPG</ImagePath>
                    <Component>1</Component>
                    <NearDepth>96.340017021748238</NearDepth>
                    <MedianDepth>172.24223128123842</MedianDepth>
                    <FarDepth>217.82134631044048</FarDepth>
                    <Pose>
                        <Rotation>
                            <M_00>0.90141918590416736</M_00>
                            <M_01>0.15828372072222782</M_01>
                            <M_02>0.40297607253805434</M_02>
                            <M_10>0.11875130300911198</M_10>
                            <M_11>-0.98546916960043185</M_11>
                            <M_12>0.1214439945022944</M_12>
                            <M_20>0.41634310288211274</M_20>
                            <M_21>-0.061618012961820047</M_21>
                            <M_22>-0.90711721467577244</M_22>
                        </Rotation>
                        <Center>
                            <x>-1966141.1331048731</x>
                            <y>4588592.5942531051</y>
                            <z>3957948.9479351165</z>
                        </Center>
                        <Metadata>
                            <SRSId>3</SRSId>
                            <Center>
                                <x>113.1943855</x>
                                <y>38.596440970000003</y>
                                <z>876.96609999999998</z>
                            </Center>
                        </Metadata>
                    </Pose>
                    <ExifData>
                        <ImageDimensions>
                            <x>6000</x>
                            <y>4000</y>
                        </ImageDimensions>
                        <Make>SONY</Make>
                        <Model>ILCE-6000</Model>
                    </ExifData>
                </Photo>

  • 写回答

16条回答 默认 最新

  • 专家-郭老师 Java领域新星创作者 2023-11-22 17:52
    关注
    获得0.60元问题酬金

    xml信息呢?以下仅供参考
    要将无人机影像的像素坐标转换为世界坐标,您需要知道相机的内外参数。内参数包括相机的焦距、主点坐标等,而外参数包括相机的旋转矩阵和平移向量。这些参数通常通过相机标定来获取。

    以下是大致的步骤:

    1. 相机标定: 使用标定板等方法,通过拍摄多个不同角度的图像来获取相机的内外参数。通常使用标定软件(如OpenCV中的cv2.calibrateCamera)。

    2. 像素坐标到相机坐标的转换: 使用相机内参数,将像素坐标(u,v)转换为相机坐标(x,y,z)。这可以通过以下公式实现:

      Xc = (u - cx) / fx
      Yc = (v - cy) / fy
      

      其中 (cx, cy) 是主点坐标,(fx, fy) 是焦距。

    3. 相机坐标到世界坐标的转换: 使用相机的外参数,将相机坐标(Xc,Yc,Zc)转换为世界坐标(Xw,Yw,Zw)。这可以通过以下公式实现:

      | Xw |     | r11 r12 r13 tx |   | Xc |
      | Yw |  =  | r21 r22 r23 ty | * | Yc |
      | Zw |     | r31 r32 r33 tz |   | Zc |
      

      其中 (r11, r12, r13, tx) 是旋转矩阵和平移向量的元素,(r21, r22, r23, ty)(r31, r32, r33, tz) 类似。

    4. 检测物体并计算世界坐标: 使用YoloV5或其他目标检测方法检测感兴趣的物体,获取其像素坐标(u,v)。然后,将像素坐标转换为相机坐标,再将相机坐标转换为世界坐标。

    注意:在实际应用中,您可能需要处理图像坐标系和相机坐标系之间的差异,通常是通过将Z坐标设置为物体到相机的距离来近似处理。

    这是一个复杂的过程,需要确保相机标定准确,并且外参数与实际场景相匹配。建议使用相机标定工具和相关库(如OpenCV)来简化这个过程。

    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 11月30日
  • 修改了问题 11月22日
  • 创建了问题 11月22日

悬赏问题

  • ¥15 岛津txt格式文件转nirs格式
  • ¥15 石墨烯磁表面等离子体
  • ¥15 angular 项目无法启动
  • ¥15 安装wampserver,图标绿色,但是无法进入软件
  • ¥15 C++ MFC 标准库 加密解密解惑
  • ¥15 两条数据合并成一条数据
  • ¥15 Ubuntu虚拟机设置
  • ¥15 comsol三维模型中磁场为什么没有“速度(洛伦兹项)”这一选项
  • ¥15 electron 如何实现自定义安装界面
  • ¥15 关于#linux#的问题:子进程C运行“ls –l”命令,且显示“C运行ls-l命令”(语言-c语言)