-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ask user during find corner at the end to validate the data #90
base: main
Are you sure you want to change the base?
Conversation
linked to #89 |
Thank you Alex for this pull request!
|
Last thing @ANaaim, do you think you could pop that window both when clicking the intrinsics and the extrinsics? (apologies if you already did) |
I will have a look at it on Monday. |
@davidpagnon (some answer in your message)
msg_box = tkinter.messagebox.askquestion(
"Validate Calibration", "Are you satisfied with point positioning ? ", icon="warning"
)
if event.key == 'h':
# If 'h', indicates that one of the objp is not visible on image
# Displays it in red on 3D plot
if len(objp) != 0 and 'ax_3d' in globals():
count = [0 if 'count' not in globals() else count+1][0]
if 'events' not in globals():
# retrieve first objp_confirmed_notok and plot 3D
events = [event]
objp_confirmed_notok = objp[count]
ax_3d.scatter(*objp_confirmed_notok, marker='o', color='r')
fig_3d.canvas.draw()
elif count == len(objp)-1:
# if all objp have been clicked or indicated as not visible, close all
objp_confirmed = np.array([[objp[count]] if 'objp_confirmed' not in globals() else objp_confirmed+[objp[count]]][0])[:-1]
imgp_confirmed = np.array(np.expand_dims(scat.get_offsets(), axis=1), np.float32)
plt.close('all')
for var_to_delete in ['events', 'count', 'scat', 'fig_3d', 'ax_3d', 'objp_confirmed_notok']:
if var_to_delete in globals():
del globals()[var_to_delete]
else:
# retrieve other objp_confirmed_notok and plot 3D
events.append(event)
objp_confirmed_notok = objp[count]
ax_3d.scatter(*objp_confirmed_notok, marker='o', color='r')
fig_3d.canvas.draw()
else:
pass For the last bit, maybe the function on_key and on_click should be renamed menu_event and adding_point_event (or something like this) |
You are right, this is strange, I could have made a mistake.
Sure, that sounds coherent! I'm all up for something clearer (as long as it still works :) ) |
Work with intrinsic as well as it is using the same function. |
Cool, the messagebox is now closing, and it shows both for intrinsics and for extrinsics! A couple last remarks:
|
I tested the h button with board, it seemed to work fine. Is there different stuff associated with using a scene that could result in this behavior ? |
Not sure to understand where it should be put for this : I added objpoints = np.array(objpoints) L605, otherwise I've got an error when clicking intrinsic parameters: imgp_confirmed = findCorners(img_path, intrinsics_corners_nb, objp=objp, show=show_detection_intrinsics)
if isinstance(imgp_confirmed, np.ndarray):
imgpoints.append(imgp_confirmed)
objpoints.append(objp) Should become this ? : imgp_confirmed = findCorners(img_path, intrinsics_corners_nb, objp=objp, show=show_detection_intrinsics)
if isinstance(imgp_confirmed, np.ndarray):
objpoints = np.array(objpoints)
imgpoints.append(imgp_confirmed)
objpoints.append(objp) |
Oh yes sorry the lines have shifted: # calculate intrinsics
img = cv2.imread(str(img_path))
objpoints = np.array(objpoints) # <-- here (L602)
ret_cam, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, img.shape[1::-1],
None, None, flags=(cv2.CALIB_FIX_K3 + cv2.CALIB_FIX_PRINCIPAL_POINT)) I still have that issue with 'H', do you not have it at all? The error does not happen right away, but after I've done all the clicking for all images for a given camera. |
Is the error in calibration intrinsic only ? |
Ithink that the problem come from the fact that during a intrinsic calibration it create a list of associated objpoint and imgpoint that might have difference in size... as a result it might not work. But for the intrinsics calibration for me it should not be possible to do a calibration without seeing the full board... |
line: 607 objpoints = np.array(objpoints) Here all the objpoints element of the list should have the same dimension if we want to transform it to a np array. For me the H as sense only during the extrinsics calibration. (We should even deactivate H during intrinsics) |
Ok but in that case the problem is in the following function
Can it take objpoints and imgpoints that are a list of numpy array that are not the same shape ? Because each associated obj_confirmed and img_confirmed are correctly associated with the same number of point. imgpoints.append(imgp_confirmed)
objpoints.append(objp_confirmed) |
No, they need to be the same shape. I would need to go back to the code to remember the details, but the rationale for the way I did it was in The way I did it was in imgp_objp_visualizer_clicker: |
Could be good if you test also (it work fine for me)