Question about python API and computer vision module
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!