Question about python API and computer vision module

조회 수: 2 (최근 30일)
Hugo
Hugo 2024년 3월 11일
답변: Udit06 2024년 3월 19일
Hi,
I'm trying to use the geo registration between two point-clouds in python using the MATLAB python API and the function eng.estgeotform3d() (code below).
eng = matlab.engine.start_matlab()
matching_GT_poses_matlab = matlab.double(get_3D_points_from_transform(matching_GT_poses))
COLMAP_poses_matlab = matlab.double(get_3D_points_from_transform(COLMAP_poses))
result_sim = eng.estgeotform3d(matching_GT_poses_matlab, COLMAP_poses_matlab,'similarity')
result_rig = eng.estgeotform3d(matching_GT_poses_matlab, COLMAP_poses_matlab,'rigid')
# print the result directly
print(result_sim)
print(result_rig)
However the algorithm does not seem to converge :
Warning: Maximum number of trials reached. Consider increasing the maximum distance or decreasing the desired confidence.
> In coder.internal.warning (line 8)
In vision.internal.ransac.msac (line 129)
In vision.internal.geotrans.algEstimateGeometricTransform (line 47)
In estgeotform3d (line 11)
And I am unable to print the result, it only prints "<matlab.object object at 0x7f73e51eb050>". Maybe due to the lack of convergence.
In the documentation there are a few other parameters described to try to reach convergence like "MaxNumTrials" or "Confidence". But the python API returns a : TypeError: invalid keyword argument 'MaxNumTrials'
indicating the keywords aren't available.
I would highly appreicate any help on my problem,
Thanks in advance

답변 (1개)

Udit06
Udit06 2024년 3월 19일
Hi Hugo,
The reason that you are seeing the output as "<matlab.object object at 0x7f73e51eb050>" is not due to lack of convergence. It is because the estgeotform3d returns a MATLAB object and Python does not know to display it properly. To display the properties of the MATLAB object, you can create a custom function in MATLAB that takes the returned MATLAB object as input and returns the property that you want to retrieve.
For example, if you MATLAB object contains a property "Count" that you want to get, you can create the following MATLAB function
function [Count]=get_count(myObject)
Count=myObject.Count;
end
To call this MATLAB function in Python, you first have to add the folder containing your custom function to the search path using the following command
eng.addpath(r'path_to_your_matlab_function', nargout=0)
You can then directly call the custom function in Python like you normally call any other MATLAB inbuilt function as shown below:
eng.get_count(ptCloud1)
Similarly, if you want to try other parameters like "MaxNumTrials" or "Confidence", it would be better to create a custom function in MATLAB and then call the custom function in Python.
You can refer to the following documentation to understand more about calling MATLAB functions from Python.
I hope this helps.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by