apriltag icon indicating copy to clipboard operation
apriltag copied to clipboard

Reuse p and R memory from params in apriltag_pose

Open Affie opened this issue 3 years ago • 7 comments

Hi, I want to update the Julia wrapper for apriltags and I have this change that fixes an issue. Memory not owned by the function is freed and new memory is allocated. I don't know if this is the best way and I'm open to something better as long as the memory passed in is not freed in matd_destroy.

Thanks

Affie avatar Jan 25 '22 12:01 Affie

What is the motivation behind this change? The memory for t is freed and allocated again. Is this an issue? Alternatively, you are allocating and freeing tmp1, which probably has the same cost.

christian-rauch avatar Jan 25 '22 12:01 christian-rauch

In the julia wrapper the memory is managed by julia and freeing it in the orthogonal_iteration function causes a segfault. So it's not about the cost.

Affie avatar Jan 25 '22 12:01 Affie

Note, I call orthogonal_iteration directly to save on converting between julia and c types.

Affie avatar Jan 25 '22 13:01 Affie

Also note: we build binaries for easy installation and use with Julia https://github.com/JuliaBinaryWrappers/AprilTags_jll.jl/releases/tag/AprilTags-v0.1.0%2B0, it is built for all supported platforms, but I haven't tested it on other platforms. I would like to make maintenance easier and directly build from this repository, it's currently built from a fork.

Affie avatar Feb 04 '22 07:02 Affie

@mkrogius @wxmerkt If you don't know of a better way to set the matrix memory directly without creating another matrix (tmp1 and tmp2), I would go ahead with this proposal.

christian-rauch avatar Feb 04 '22 10:02 christian-rauch

@christian-rauch I am afraid I can't comment on this. @mkrogius is the best person to answer

wxmerkt avatar Feb 04 '22 18:02 wxmerkt

I'm leaning against accepting this change because somebody reading this code will not understand why this code is written this way. Surely there must be some way in the Julia wrapper to create and pass in a "t" that is a native c type and so would not segfault?

mkrogius avatar Feb 05 '22 06:02 mkrogius