ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

AP_Camera: Add Camera Tracking functionality (WIP)

Open khanasif786 opened this issue 1 year ago • 7 comments

This adds support for a companion computer to perform image tracking using any of the backends

khanasif786 avatar Aug 07 '24 01:08 khanasif786

Could you rebase this and also clarify what testing has been done?

rmackay9 avatar Aug 07 '24 01:08 rmackay9

Could you create a separate PR with the python script in a new directory AP_Camera/examples?

rmackay9 avatar Aug 07 '24 01:08 rmackay9

We should also consume the CAMERA_TRACKING_IMAGE_STATUS message and update the user

rmackay9 avatar Aug 07 '24 01:08 rmackay9

We should implement MAV_CMD_CAMERA_STOP_TRACKING

rmackay9 avatar Aug 07 '24 02:08 rmackay9

@khanasif786, thanks for all your efforts on this. Could you rebase this on master too?

Let's also make it "ready for review" instead of "WIP"

rmackay9 avatar Aug 21 '24 00:08 rmackay9

 Binary Name      Text [B]         Data [B]     BSS (B)        Total Flash Change [B] (%)      Flash Free After PR (B)
---------------  ---------------  -----------  -------------  ----------------------------  -------------------------
antennatracker   916 (+0.0688%)   0 (0.0000%)  -4 (-0.0015%)  916 (+0.0687%)                                   631372
arduplane        1048 (+0.0583%)  0 (0.0000%)  0 (0.0000%)    1048 (+0.0582%)                                  164728
blimp            916 (+0.0677%)   0 (0.0000%)  4 (+0.0015%)   916 (+0.0675%)                                   609112
arducopter-heli  1076 (+0.0598%)  0 (0.0000%)  4 (+0.0015%)   1076 (+0.0597%)                                  162656
arducopter       1072 (+0.0596%)  0 (0.0000%)  0 (0.0000%)    1072 (+0.0594%)                                  161680
ardusub          1088 (+0.0684%)  0 (0.0000%)  0 (0.0000%)    1088 (+0.0683%)                                  371252
ardurover        1060 (+0.0643%)  0 (0.0000%)  4 (+0.0015%)   1060 (+0.0642%)                                  313360

amilcarlucas avatar Aug 31 '24 09:08 amilcarlucas

@khanasif786, I think perhaps the follow-functionality should be split into a separate PR, with this one focussing on the core camera tracking changes.

The addition of MSG_CAMERA_TRACKING_IMAGE_STATUS is needed though if we are to run the tracker on a companion computer and want to send the GCS information about the current bounding box so it can be displayed in the GUI. I'm running into just this issue in testing.

I've written a MAVProxy module (camtrack) to test this PR in simulation and on hardware. There's a mavproxy GUI module to engage / disengage the tracker, and a separate headless module that may run on either the GCS computer, or on the companion computer.

It's working in simulation, still having a few issues setting up correct sys_id and component_id for all components on hardware (CubeOrangePlus with RPi4 companion). AFAICT the RPi4 copes with the cv2.legacy.TrackerCSTR tracker.

The MAVProxy code is here: https://github.com/srmainwaring/MAVProxy/tree/wips/wip-camera-tracking. It is a WIP with a lot of debug message code included that will eventually be pruned. Let me know if you'd like a walk through.

A rebase of this PR on master here: https://github.com/srmainwaring/ardupilot/tree/mav_cmd_camera_final_rebased. I'd force push, but don't have access. There are a few conflicts resolved.

srmainwaring avatar Oct 07 '24 19:10 srmainwaring

@khanasif786 are you still working on this?

vicradon avatar Jan 30 '25 11:01 vicradon

@vicradon , Yes! Testing phase. do you have any suggestions or something let me know.

khanasif786 avatar Mar 30 '25 07:03 khanasif786

The architecture of the Follow Library has been changed so much, which is why the merge conflict, So eventually this PULL will require so much rework. Let me come back here with a new and compatible patch

khanasif786 avatar Aug 16 '25 10:08 khanasif786

The new working PR is here - #30941

khanasif786 avatar Aug 19 '25 16:08 khanasif786