parent
75fcfa6093
commit
e5763fae4b
5 changed files with 68 additions and 19 deletions
@ -0,0 +1,17 @@ |
||||
#ifdef HAVE_OPENCV_SURFACE_MATCHING |
||||
|
||||
template<> struct pyopencvVecConverter<ppf_match_3d::Pose3DPtr > |
||||
{ |
||||
static bool to(PyObject* obj, std::vector<ppf_match_3d::Pose3DPtr >& value, const ArgInfo info) |
||||
{ |
||||
return pyopencv_to_generic_vec(obj, value, info); |
||||
} |
||||
|
||||
static PyObject* from(const std::vector<ppf_match_3d::Pose3DPtr >& value) |
||||
{ |
||||
return pyopencv_from_generic_vec(value); |
||||
} |
||||
}; |
||||
|
||||
typedef std::vector<ppf_match_3d::Pose3DPtr> vector_Pose3DPtr; |
||||
#endif |
@ -0,0 +1,32 @@ |
||||
import cv2 as cv |
||||
|
||||
N = 2 |
||||
modelname = "parasaurolophus_6700" |
||||
scenename = "rs1_normals" |
||||
|
||||
detector = cv.ppf_match_3d_PPF3DDetector(0.025, 0.05) |
||||
|
||||
print('Loading model...') |
||||
pc = cv.ppf_match_3d.loadPLYSimple("data/%s.ply" % modelname, 1) |
||||
|
||||
|
||||
print('Training...') |
||||
detector.trainModel(pc) |
||||
|
||||
print('Loading scene...') |
||||
pcTest = cv.ppf_match_3d.loadPLYSimple("data/%s.ply" % scenename, 1) |
||||
|
||||
print('Matching...') |
||||
results = detector.match(pcTest, 1.0/40.0, 0.05) |
||||
|
||||
print('Performing ICP...') |
||||
icp = cv.ppf_match_3d_ICP(100) |
||||
_, results = icp.registerModelToScene(pc, pcTest, results[:N]) |
||||
|
||||
print("Poses: ") |
||||
for i, result in enumerate(results): |
||||
#result.printPose() |
||||
print("\n-- Pose to Model Index %d: NumVotes = %d, Residual = %f\n%s\n" % (result.modelIndex, result.numVotes, result.residual, result.pose)) |
||||
if i == 0: |
||||
pct = cv.ppf_match_3d.transformPCPose(pc, result.pose) |
||||
cv.ppf_match_3d.writePLY(pct, "%sPCTrans.ply" % modelname) |
Loading…
Reference in new issue