Apriltag:在Coppeliasim中无法通过视觉传感器/摄像头识别tag

原因在于Coppeliasim输出的图像时关于y轴镜像的,所以导致Apriltag无法识别
可以在视觉传感器的脚本使用simVision插件进行镜像

function sysCall_init()

    -- Get some handles:
    activeVisionSensor=sim.getObjectHandle('Vision_sensor')
    visionSensor=sim.getObjectAssociatedWithScript(sim.handle_self)
    -- Enable an image publisher and subscriber:
    if simROS then
    
        print("<font color='#0F0'>ROS interface was found.</font>@html")
        pub=simROS.advertise('/floorCamera', 'sensor_msgs/Image')
        simROS.publisherTreatUInt8ArrayAsString(pub) -- treat uint8 arrays as strings (much faster, tables/arrays are kind of slow in Lua)
        
    else
        print("<font color='#F00'>ROS interface was not found. Cannot run.</font>@html")
    end
end

function sysCall_sensing()
	--触发视觉处理回调函数
    local trigger,packet1,packet2=sim.handleVisionSensor(visionSensor)

    if simROS then
        --set /use_sim_time to true
        simROS.publish(clockpub,{clock=sim.getSystemTime()})
        -- Publish the image of the active vision sensor:
        local data,w,h=sim.getVisionSensorCharImage(activeVisionSensor)
        d={}
        d['header']={stamp=sim.getSystemTime(), frame_id="floorCamera_link"}
        d['height']=h
        d['width']=w
        d['encoding']='rgb8'
        d['is_bigendian']=1
        d['step']=w*3
        d['data']=data
        simROS.publish(pub,d)       
    end
end

function sysCall_cleanup()
    if simROS then
        -- Shut down publisher and subscriber. Not really needed from a simulation script (automatic shutdown)
        simROS.shutdownPublisher(pub)
    end
end

function sysCall_vision(inData)

    simVision.sensorImgToWorkImg(inData.handle)
    simVision.horizontalFlipWorkImg(inData.handle)
    simVision.workImgToSensorImg(inData.handle)

end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值