Home > other >  Opencv surface_matching in ubuntu 16.04 segmentation fault (core dumped) problem
Opencv surface_matching in ubuntu 16.04 segmentation fault (core dumped) problem

Time:12-02

Below is my original code, and compiled on the ros ubuntu16.4
Input of different field spots cloud can sometimes normal match and rt matrix
Bothering me for a long time, sometimes produce Segmentation fault problem
Use GDB debugging, found the program to run to
The detector. The match (* pcTest, results, 1.0/5.0, 0.03);
After will appear segfault and interrupt program
Online for a long time found that may be memory overflow, and so on question (not sure)
But I don't know how to allocate memory


#include
#include
#include
#include
#include
#include
# include "opencv2/surface_matching HPP"
#include
# include "opencv2/surface_matching/ppf_helpers HPP"
# include "opencv2/core/utility. HPP"

using namespace std;
Using the namespace CV;
Using the namespace ppf_match_3d;

/* static void help (const string& ErrorMessage)
{

cout <"The Program init error:" & lt; cout <"\ nUsage: ppf_matching [input model file] [input scene file]" & lt; cout <"\ nPlease start again with new parameters" & lt; } */

Int main (int arg c, char * * argv)
{
//the welcome message
cout <"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" & lt; cout <"* Surface Matching individual: demonstrates the use of Surface Matching", "
"Using point pair the features." & lt; cout <"* The sample loads a model and a scene, where The model lies in a company's"
The "pose than training. \ n * It then trains the model and searches for It in the"
"The input scene. The detected poses are further refined by ICP \ n * and printed to The"
"The standard output." & lt; cout <"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" & lt;
/* if (arg c & lt; 3)
{
Help (" Not enough input arguments ");
cout exit(1);
} */

# if (defined __x86_64__ | | defined _M_X64)
cout <"Running on 64 bits" & lt; //typedef uint64_t KeyType;
# the else
cout <"Running on 32 bits" & lt; //typedef unsigned int KeyType;
# endif

# ifdef _OPENMP
cout <"Running with OpenMP" & lt; # the else
cout <"Running without OpenMP and without TBB" & lt; # endif

String modelFileName="/home/mingchi catkin_ws/SRC/opencv_test/table3. The ply";
String sceneFileName="/home/mingchi catkin_ws/SRC/opencv_test/test. The ply";

P1 int64 *;
Int64 * (p2);
Mat * PC;
Mat * pcTest;


Mat pc_1=loadPLYSimple (modelFileName c_str (), 1);
//Mat PC=loadPLYSimple ("/home/mingchi catkin_ws/SRC/opencv_test/box2. The ply ", 1);
PC=& amp; Pc_1;
//Now train the model
cout <"Training... "& lt; Int64 tick1=CV: : getTickCount ();
P1=& amp; Tick1;
Ppf_match_3d: : PPF3DDetector detector (0.025, 0.05);
The detector. TrainModel (* PC);
Int64 tick2=CV: : getTickCount ();
The p2=& amp; Tick2;
cout <"The SEC" & lt; //Read the scene
Mat pcTest_1=loadPLYSimple (sceneFileName c_str (), 1);
//Mat pcTest=loadPLYSimple ("/home/mingchi catkin_ws/SRC/opencv_test/test. The ply ", 1);
PcTest=& amp; PcTest_1;
cout
//Match the model to the scene and the get the pose
cout VectorInt64 tick3=CV: : getTickCount ();
* p1=tick3;
The detector. The match (* pcTest, results, 1.0/5.0, 0.03);
Int64 tick4=CV: : getTickCount ();
* the p2=tick4;
cout P2 (* - * (p1)/CV: : getTickFrequency () & lt; <"The SEC" & lt; //size_t results_size=the size ();

//cout & lt; <"The Number of matching poses:" & lt;
/* if (results_size==0) {
cout exit(0);
} */

//Get only the first N the results
Int N=1;
/* if (results_size & lt; N) {
cout N=results_size;
} */
Vector
//Create an instance of ICP (iterations, how rejection scale, numlevels)
ICP, ICP (100, 0.05 f to 2.5 f, 8).
Int64 t1=CV: : getTickCount ();
* p1=t1;
//Register for all selected poses
cout Icp. RegisterModelToScene (* PC, * pcTest, resultsSub);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related