java - OpenCV SIMPLEBLOB not detecting any blobs -


i trying implement simpleblob opencv in android application. however, when try run featuredetector.detect(...) can not find blobs , not sure why.

as input, have 2d array (for example)

[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 116, 211, 112, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 26, 240, 255, 217, 24, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 24, 229, 255, 236, 32, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 145, 246, 189, 26, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 42, 91, 62, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 23, 32, 26, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] 

which convert mat via

matrixasmat = new mat(27, 15, cvtype.cv_8uc1);     (int = 0; < 27; i++) {         (int j = 0; j < 15; j++)             matrixasmat.put(i, j, matrix[i][j]);     } 

i insert mat featuredetector (see below) , try detect blobs. however, can never seem find any.

matofkeypoint matofkeypoints = new matofkeypoint();   featuredetector blobdetector = featuredetector.create(featuredetector.simpleblob); file input = new file(environment.getexternalstoragedirectory().getabsolutepath() + "/blob.xml"); if(!input.exists()) {     try {         writeparams();         log.d("written", "param written");      } catch (ioexception e) {          e.printstacktrace();      } }  blobdetector.read(environment.getexternalstoragedirectory().getabsolutepath() + "/blob.xml"); blobdetector.detect(matrixasmat, matofkeypoints);  log.d("matirx", arrays.deeptostring(matrix));  log.d("detected ", matofkeypoints.size().tostring() + " blobs in image");  list<keypoint> keypoints = matofkeypoints.tolist();  list<matofpoint> contours = new arraylist<>();  mat matrixasmat2 = new mat(); mat hierarchy = new mat(); imgproc.threshold(matrixasmat, matrixasmat2, getmean(matrix) * 0.8, 255, imgproc.thresh_binary); imgproc.findcontours(matrixasmat2, contours, hierarchy, imgproc.retr_tree, imgproc.chain_approx_tc89_l1); 

creation of blob.xml

file input = new file(environment.getexternalstoragedirectory().getabsolutepath() + "/blob.xml"); string blobparams = ""; blobparams = "<?xml version=\"1.0\"?>\n" +      "<opencv_storage>\n" +      "<minthreshold>1.</minthreshold>\n" +                "<filterbyarea>1</filterbyarea>\n" +      "<minarea>3.</minarea>\n" +      "<filterbycircularity>0</filterbycircularity>\n" +               "<mincircularity>0.1</mincircularity>\n" +      "<filterbyinertia>0</filterbyinertia>\n" +      "<mininertiaratio>0.01</mininertiaratio>\n" +     "<filterbyconvexity>0</filterbyconvexity>\n" +         "minconvexity>0.2</minconvexity>\n" +      "</opencv_storage>";  filewriter writer = new filewriter(input); writer.append(blobparams); writer.flush(); writer.close(); 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -