SolvePnP keep crashing for unknown reasons

I’m sorry I did not explain my problem. So I will detail it here. I have a screwdriver on which I put green markers (so almost a cylinder).

1

I am able to extract these markers using the right HSV values and create a mask to retrieve all of them.

3

2

Using this mask I find the image contours, highlighted in blue on the picture (don’t mind the red dot). I then create an array of cv::Point corresponding to each contour center point on the image. So these are my image points.

Now I want the pose estimation of my screwdriver using these image points, and knowing their 3D disposition in the screwdriver world. This is possible using fiducial markers like aruco since they have a unique ID, but Aruco is planar pose estimation, and they don’t work at long distances. The whole point is to achieve pose estimation using only the data I described (or not a lot much).