Java Code Examples for org.opencv.features2d.FeatureDetector.create()

The following are Jave code examples for showing how to use create() of the org.opencv.features2d.FeatureDetector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: zooracle   File: KMeansMatcher.java   View Source Code Vote up 5 votes
public KMeansMatcher()
{
	model = null;
	featureDetector = FeatureDetector.create(FeatureDetector.PYRAMID_ORB);
	descriptorExtractor = DescriptorExtractor.create(DescriptorExtractor.BRIEF);
	matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_SL2);
}
 
Example 2
Project: MotionTracker_SmartRoom   File: MotionTracker.java   View Source Code Vote up 5 votes
/**
 * Creates a new motion tracker that updates the x and y coordinates in the given Coordinate object.
 * @param coords 
 */
public MotionTracker(Coordinate coords) {
    // create a blob detector with the parameters from the param file
    // (especially used to ignore small blobs and those that are very close together)
    blobDetector = FeatureDetector.create(FeatureDetector.SIMPLEBLOB);
    blobDetector.read(PARAMS);
    
    this.coords = coords;
}
 
Example 3
Project: second_eyes   File: ExtractPath.java   View Source Code Vote up 5 votes
public ExtractPath() {
    super();

    mKeyPointsPrev = new MatOfKeyPoint();
    // set up feature detection
    try {
        mFeatureDectector = FeatureDetector.create(FeatureDetector.FAST);
    } catch (UnsatisfiedLinkError err) {
        Log.e(TAG, "Feature detector failed with");
        err.printStackTrace();
    }
    // set up description detection
    mDescExtractor = DescriptorExtractor.create(DescriptorExtractor.BRISK);
    mDescMatcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);

    mPrevFrame = new Mat();
    prevKeyPoints = new MatOfKeyPoint();
    RGBFrame = new Mat();
    mForeGroundMask = new Mat();
    mContours = new ArrayList<MatOfPoint>();
    //creates a new BackgroundSubtractorMOG class with the arguments
    mBackgroundSub = Video.createBackgroundSubtractorMOG2(50, 0, true);
}
 
Example 4
Project: StormCV   File: PartialMatcher.java   View Source Code Vote up 5 votes
/**
 * Calculates descriptors as defined by detectorType and 
 * descriptorType provided at construction for the provided image
 * @param input
 * @return
 * @throws IOException
 */
private Mat calculateDescriptors(byte[] buffer) throws IOException{
	MatOfByte mob = new MatOfByte(buffer);
	Mat image = Highgui.imdecode(mob, Highgui.CV_LOAD_IMAGE_ANYCOLOR);
	
	FeatureDetector siftDetector = FeatureDetector.create(detectorType);
	MatOfKeyPoint mokp = new MatOfKeyPoint();
	siftDetector.detect(image, mokp);
	
	Mat descriptors = new Mat();
	DescriptorExtractor extractor = DescriptorExtractor.create(descriptorType);
	extractor.compute(image, mokp, descriptors);
	return descriptors;
}
 
Example 5
Project: StormCV   File: FeatureMatcherOp.java   View Source Code Vote up 5 votes
/**
 * Calculates descriptors as defined by detectorType and 
 * descriptorType provided at construction for the provided image
 * @param input
 * @return
 * @throws IOException
 */
private Mat calculateDescriptors(byte[] buffer) throws IOException{
	MatOfByte mob = new MatOfByte(buffer);
	Mat image = Highgui.imdecode(mob, Highgui.CV_LOAD_IMAGE_ANYCOLOR);
	
	FeatureDetector siftDetector = FeatureDetector.create(detectorType);
	MatOfKeyPoint mokp = new MatOfKeyPoint();
	siftDetector.detect(image, mokp);
	
	Mat descriptors = new Mat();
	DescriptorExtractor extractor = DescriptorExtractor.create(descriptorType);
	extractor.compute(image, mokp, descriptors);
	return descriptors;
}
 
Example 6
Project: OpenCvSample   File: MyActivity.java   View Source Code Vote up 5 votes
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS:
            try {
                target = Utils.loadResource(MyActivity.this, R.raw.f1, Highgui.CV_LOAD_IMAGE_COLOR);
                detector = FeatureDetector.create(FeatureDetector.ORB);
                extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);

                MatOfKeyPoint keyPoint = new MatOfKeyPoint();
                Mat descriptors = new Mat();

                long time = System.currentTimeMillis();
                detector.detect(target, keyPoint);
                extractor.compute(target, keyPoint, descriptors);
                Log.d("opencv", "计算关键点耗时(毫秒): " + (System.currentTimeMillis() - time) +
                        ", 关键点总数: " + keyPoint.toArray().length);

                for (KeyPoint k : keyPoint.toArray()) {
                    Core.circle(target, k.pt, 5, new Scalar(255, 0, 0));
                }

                Mat tmp = new Mat(target.cols(), target.rows(), CvType.CV_8U, new Scalar(4));
                Bitmap image = Bitmap.createBitmap(target.cols(), target.rows(), Bitmap.Config.ARGB_8888);
                Imgproc.cvtColor(target, tmp, Imgproc.COLOR_RGB2BGRA, 4);
                Utils.matToBitmap(tmp, image);
                myImageView.setImageBitmap(image);

            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        default:
            super.onManagerConnected(status);
    }
}
 
Example 7
Project: fingerblox   File: ImageProcessing.java   View Source Code Vote up 4 votes
@NonNull
private Mat detectFeatures(Mat skeleton, Mat edges) {
    FeatureDetector star = FeatureDetector.create(FeatureDetector.ORB);
    DescriptorExtractor brief = DescriptorExtractor.create(DescriptorExtractor.ORB);

    MatOfKeyPoint keypoints = new MatOfKeyPoint();
    star.detect(skeleton, keypoints);
    keypointsField = keypoints;

    KeyPoint[] keypointArray = keypoints.toArray();
    ArrayList<KeyPoint> filteredKeypointArray = new ArrayList<>(keypointArray.length);

    int filterCount = 0;
    for (KeyPoint k : keypointArray) {
        if (edges.get((int)k.pt.y, (int)k.pt.x)[0] <= 0.0) {
            k.size /= 8;
            filteredKeypointArray.add(k);
        } else {
            filterCount++;
        }
    }
    Log.d(TAG, String.format("Filtered %s Keypoints", filterCount));

    keypoints.fromList(filteredKeypointArray);

    Mat descriptors = new Mat();
    brief.compute(skeleton, keypoints, descriptors);
    descriptorsField = descriptors;

    Mat results = new Mat();
    Scalar color = new Scalar(255, 0, 0); // RGB
    Features2d.drawKeypoints(skeleton, keypoints, results, color, Features2d.DRAW_RICH_KEYPOINTS);
    return results;
}
 
Example 8
Project: RobotIGS   File: ObjectDetection.java   View Source Code Vote up 4 votes
/**
 * Instantiate an object detector based on the FAST, BRIEF, and BRUTEFORCE_HAMMING algorithms
 */
public ObjectDetection() {
    detector = FeatureDetector.create(FeatureDetectorType.FAST.val());
    extractor = DescriptorExtractor.create(DescriptorExtractorType.BRIEF.val());
    matcher = DescriptorMatcher.create(DescriptorMatcherType.BRUTEFORCE_HAMMING.val());
}
 
Example 9
Project: FtcSamples   File: GripPipelineRedJewel.java   View Source Code Vote up 4 votes
/**
 * Detects groups of pixels in an image.
 * @param input The image on which to perform the find blobs.
 * @param minArea The minimum size of a blob that will be found
 * @param circularity The minimum and maximum circularity of blobs that will be found
 * @param darkBlobs The boolean that determines if light or dark blobs are found.
 * @param blobList The output where the MatOfKeyPoint is stored.
 */
private void findBlobs(Mat input, double minArea, double[] circularity,
	Boolean darkBlobs, MatOfKeyPoint blobList) {
	FeatureDetector blobDet = FeatureDetector.create(FeatureDetector.SIMPLEBLOB);
	try {
		File tempFile = File.createTempFile("config", ".xml");

		StringBuilder config = new StringBuilder();

		config.append("<?xml version=\"1.0\"?>\n");
		config.append("<opencv_storage>\n");
		config.append("<thresholdStep>10.</thresholdStep>\n");
		config.append("<minThreshold>50.</minThreshold>\n");
		config.append("<maxThreshold>220.</maxThreshold>\n");
		config.append("<minRepeatability>2</minRepeatability>\n");
		config.append("<minDistBetweenBlobs>10.</minDistBetweenBlobs>\n");
		config.append("<filterByColor>1</filterByColor>\n");
		config.append("<blobColor>");
		config.append((darkBlobs ? 0 : 255));
		config.append("</blobColor>\n");
		config.append("<filterByArea>1</filterByArea>\n");
		config.append("<minArea>");
		config.append(minArea);
		config.append("</minArea>\n");
		config.append("<maxArea>");
		config.append(Integer.MAX_VALUE);
		config.append("</maxArea>\n");
		config.append("<filterByCircularity>1</filterByCircularity>\n");
		config.append("<minCircularity>");
		config.append(circularity[0]);
		config.append("</minCircularity>\n");
		config.append("<maxCircularity>");
		config.append(circularity[1]);
		config.append("</maxCircularity>\n");
		config.append("<filterByInertia>1</filterByInertia>\n");
		config.append("<minInertiaRatio>0.1</minInertiaRatio>\n");
		config.append("<maxInertiaRatio>" + Integer.MAX_VALUE + "</maxInertiaRatio>\n");
		config.append("<filterByConvexity>1</filterByConvexity>\n");
		config.append("<minConvexity>0.95</minConvexity>\n");
		config.append("<maxConvexity>" + Integer.MAX_VALUE + "</maxConvexity>\n");
		config.append("</opencv_storage>\n");
		FileWriter writer;
		writer = new FileWriter(tempFile, false);
		writer.write(config.toString());
		writer.close();
		blobDet.read(tempFile.getPath());
	} catch (IOException e) {
		e.printStackTrace();
	}

	blobDet.detect(input, blobList);
}
 
Example 10
Project: FtcSamples   File: GripPipelineBlueJewel.java   View Source Code Vote up 4 votes
/**
 * Detects groups of pixels in an image.
 * @param input The image on which to perform the find blobs.
 * @param minArea The minimum size of a blob that will be found
 * @param circularity The minimum and maximum circularity of blobs that will be found
 * @param darkBlobs The boolean that determines if light or dark blobs are found.
 * @param blobList The output where the MatOfKeyPoint is stored.
 */
private void findBlobs(Mat input, double minArea, double[] circularity,
	Boolean darkBlobs, MatOfKeyPoint blobList) {
	FeatureDetector blobDet = FeatureDetector.create(FeatureDetector.SIMPLEBLOB);
	try {
		File tempFile = File.createTempFile("config", ".xml");

		StringBuilder config = new StringBuilder();

		config.append("<?xml version=\"1.0\"?>\n");
		config.append("<opencv_storage>\n");
		config.append("<thresholdStep>10.</thresholdStep>\n");
		config.append("<minThreshold>50.</minThreshold>\n");
		config.append("<maxThreshold>220.</maxThreshold>\n");
		config.append("<minRepeatability>2</minRepeatability>\n");
		config.append("<minDistBetweenBlobs>10.</minDistBetweenBlobs>\n");
		config.append("<filterByColor>1</filterByColor>\n");
		config.append("<blobColor>");
		config.append((darkBlobs ? 0 : 255));
		config.append("</blobColor>\n");
		config.append("<filterByArea>1</filterByArea>\n");
		config.append("<minArea>");
		config.append(minArea);
		config.append("</minArea>\n");
		config.append("<maxArea>");
		config.append(Integer.MAX_VALUE);
		config.append("</maxArea>\n");
		config.append("<filterByCircularity>1</filterByCircularity>\n");
		config.append("<minCircularity>");
		config.append(circularity[0]);
		config.append("</minCircularity>\n");
		config.append("<maxCircularity>");
		config.append(circularity[1]);
		config.append("</maxCircularity>\n");
		config.append("<filterByInertia>1</filterByInertia>\n");
		config.append("<minInertiaRatio>0.1</minInertiaRatio>\n");
		config.append("<maxInertiaRatio>" + Integer.MAX_VALUE + "</maxInertiaRatio>\n");
		config.append("<filterByConvexity>1</filterByConvexity>\n");
		config.append("<minConvexity>0.95</minConvexity>\n");
		config.append("<maxConvexity>" + Integer.MAX_VALUE + "</maxConvexity>\n");
		config.append("</opencv_storage>\n");
		FileWriter writer;
		writer = new FileWriter(tempFile, false);
		writer.write(config.toString());
		writer.close();
		blobDet.read(tempFile.getPath());
	} catch (IOException e) {
		e.printStackTrace();
	}

	blobDet.detect(input, blobList);
}
 
Example 11
Project: FtcSamples   File: GripPipeline.java   View Source Code Vote up 4 votes
/**
 * Detects groups of pixels in an image.
 * @param input The image on which to perform the find blobs.
 * @param minArea The minimum size of a blob that will be found
 * @param circularity The minimum and maximum circularity of blobs that will be found
 * @param darkBlobs The boolean that determines if light or dark blobs are found.
 * @param blobList The output where the MatOfKeyPoint is stored.
 */
private void findBlobs(Mat input, double minArea, double[] circularity,
	Boolean darkBlobs, MatOfKeyPoint blobList) {
	FeatureDetector blobDet = FeatureDetector.create(FeatureDetector.SIMPLEBLOB);
	try {
		File tempFile = File.createTempFile("config", ".xml");

		StringBuilder config = new StringBuilder();

		config.append("<?xml version=\"1.0\"?>\n");
		config.append("<opencv_storage>\n");
		config.append("<thresholdStep>10.</thresholdStep>\n");
		config.append("<minThreshold>50.</minThreshold>\n");
		config.append("<maxThreshold>220.</maxThreshold>\n");
		config.append("<minRepeatability>2</minRepeatability>\n");
		config.append("<minDistBetweenBlobs>10.</minDistBetweenBlobs>\n");
		config.append("<filterByColor>1</filterByColor>\n");
		config.append("<blobColor>");
		config.append((darkBlobs ? 0 : 255));
		config.append("</blobColor>\n");
		config.append("<filterByArea>1</filterByArea>\n");
		config.append("<minArea>");
		config.append(minArea);
		config.append("</minArea>\n");
		config.append("<maxArea>");
		config.append(Integer.MAX_VALUE);
		config.append("</maxArea>\n");
		config.append("<filterByCircularity>1</filterByCircularity>\n");
		config.append("<minCircularity>");
		config.append(circularity[0]);
		config.append("</minCircularity>\n");
		config.append("<maxCircularity>");
		config.append(circularity[1]);
		config.append("</maxCircularity>\n");
		config.append("<filterByInertia>1</filterByInertia>\n");
		config.append("<minInertiaRatio>0.1</minInertiaRatio>\n");
		config.append("<maxInertiaRatio>" + Integer.MAX_VALUE + "</maxInertiaRatio>\n");
		config.append("<filterByConvexity>1</filterByConvexity>\n");
		config.append("<minConvexity>0.95</minConvexity>\n");
		config.append("<maxConvexity>" + Integer.MAX_VALUE + "</maxConvexity>\n");
		config.append("</opencv_storage>\n");
		FileWriter writer;
		writer = new FileWriter(tempFile, false);
		writer.write(config.toString());
		writer.close();
		blobDet.read(tempFile.getPath());
	} catch (IOException e) {
		e.printStackTrace();
	}

	blobDet.detect(input, blobList);
}
 
Example 12
Project: OpencvAndroid   File: MainActivity.java   View Source Code Vote up 4 votes
private void initializeOpenCVDependencies() throws IOException {
    mOpenCvCameraView.enableView();
    detector = FeatureDetector.create(FeatureDetector.ORB);
    descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);
    matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
    img1 = new Mat();
    AssetManager assetManager = getAssets();
    InputStream istr = assetManager.open("a.jpeg");
    Bitmap bitmap = BitmapFactory.decodeStream(istr);
    Utils.bitmapToMat(bitmap, img1);
    Imgproc.cvtColor(img1, img1, Imgproc.COLOR_RGB2GRAY);
    img1.convertTo(img1, 0); //converting the image to match with the type of the cameras image
    descriptors1 = new Mat();
    keypoints1 = new MatOfKeyPoint();
    detector.detect(img1, keypoints1);
    descriptor.compute(img1, keypoints1, descriptors1);

}
 
Example 13
Project: liastem   File: Grip1 copy.java   View Source Code Vote up 4 votes
/**
 * Detects groups of pixels in an image.
 * @param input The image on which to perform the find blobs.
 * @param minArea The minimum size of a blob that will be found
 * @param circularity The minimum and maximum circularity of blobs that will be found
 * @param darkBlobs The boolean that determines if light or dark blobs are found.
 * @param blobList The output where the MatOfKeyPoint is stored.
 */
private void findBlobs(Mat input, double minArea, double[] circularity,
	Boolean darkBlobs, MatOfKeyPoint blobList) {
	FeatureDetector blobDet = FeatureDetector.create(FeatureDetector.SIMPLEBLOB);
	try {
		File tempFile = File.createTempFile("config", ".xml");

		StringBuilder config = new StringBuilder();

		config.append("<?xml version=\"1.0\"?>\n");
		config.append("<opencv_storage>\n");
		config.append("<thresholdStep>10.</thresholdStep>\n");
		config.append("<minThreshold>50.</minThreshold>\n");
		config.append("<maxThreshold>220.</maxThreshold>\n");
		config.append("<minRepeatability>2</minRepeatability>\n");
		config.append("<minDistBetweenBlobs>10.</minDistBetweenBlobs>\n");
		config.append("<filterByColor>1</filterByColor>\n");
		config.append("<blobColor>");
		config.append((darkBlobs ? 0 : 255));
		config.append("</blobColor>\n");
		config.append("<filterByArea>1</filterByArea>\n");
		config.append("<minArea>");
		config.append(minArea);
		config.append("</minArea>\n");
		config.append("<maxArea>");
		config.append(Integer.MAX_VALUE);
		config.append("</maxArea>\n");
		config.append("<filterByCircularity>1</filterByCircularity>\n");
		config.append("<minCircularity>");
		config.append(circularity[0]);
		config.append("</minCircularity>\n");
		config.append("<maxCircularity>");
		config.append(circularity[1]);
		config.append("</maxCircularity>\n");
		config.append("<filterByInertia>1</filterByInertia>\n");
		config.append("<minInertiaRatio>0.1</minInertiaRatio>\n");
		config.append("<maxInertiaRatio>" + Integer.MAX_VALUE + "</maxInertiaRatio>\n");
		config.append("<filterByConvexity>1</filterByConvexity>\n");
		config.append("<minConvexity>0.95</minConvexity>\n");
		config.append("<maxConvexity>" + Integer.MAX_VALUE + "</maxConvexity>\n");
		config.append("</opencv_storage>\n");
		FileWriter writer;
		writer = new FileWriter(tempFile, false);
		writer.write(config.toString());
		writer.close();
		blobDet.read(tempFile.getPath());
	} catch (IOException e) {
		e.printStackTrace();
	}

	blobDet.detect(input, blobList);
}
 
Example 14
Project: 2016-FTC   File: ObjectDetection.java   View Source Code Vote up 4 votes
/**
 * Instantiate an object detector based on the FAST, BRIEF, and BRUTEFORCE_HAMMING algorithms
 */
public ObjectDetection() {
    detector = FeatureDetector.create(FeatureDetectorType.FAST.val());
    extractor = DescriptorExtractor.create(DescriptorExtractorType.BRIEF.val());
    matcher = DescriptorMatcher.create(DescriptorMatcherType.BRUTEFORCE_HAMMING.val());
}
 
Example 15
Project: ImageDetectionCordovaPlugin   File: ImageDetectionPlugin.java   View Source Code Vote up 4 votes
@Override
public void surfaceCreated(SurfaceHolder holder) {
    matches = new MatOfDMatch();
    orbDetector = FeatureDetector.create(FeatureDetector.ORB);
    orbDescriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);
    kp2 = new MatOfKeyPoint();
    desc2 = new Mat();
}
 
Example 16
Project: OpenCVTour   File: ImageDetector.java   View Source Code Vote up 4 votes
public ImageDetector(int detector_type, int extractor_type, int matcher_type)
{
	fDetector = FeatureDetector.create
			(detector_type);
	dExtractor = DescriptorExtractor.create
			(extractor_type);
	dMatcher= DescriptorMatcher.create
			(matcher_type);
	training_library= new ArrayList<TrainingImage>();
	
	// Specific values selected after experimenting with different data sets
	max_side = 300;
	filter_ratio = 5;
	distance_bound = 50;
}
 
Example 17
Project: FTCVision   File: ObjectDetection.java   View Source Code Vote up 4 votes
/**
 * Instantiate an object detector based on the FAST, BRIEF, and BRUTEFORCE_HAMMING algorithms
 */
public ObjectDetection() {
    detector = FeatureDetector.create(FeatureDetectorType.FAST.val());
    extractor = DescriptorExtractor.create(DescriptorExtractorType.BRIEF.val());
    matcher = DescriptorMatcher.create(DescriptorMatcherType.BRUTEFORCE_HAMMING.val());
}
 
Example 18
Project: OpenCV-BackProjection   File: BackProjectionActivity.java   View Source Code Vote up 4 votes
private void testMatSerialization(){
	File storage = Environment.getExternalStorageDirectory();
	String path = storage.getAbsolutePath()+"/opencv/file.bin";
	
	FeatureDetector detector = FeatureDetector.create(FeatureDetector.GRID_ORB);
	DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
	
	MatOfKeyPoint kpts = new MatOfKeyPoint();
	detector.detect(mRgba, kpts);
	
	Mat descriptors = new Mat();
	extractor.compute(mGray, kpts, descriptors);
	
	Log.d(TAG, "test - descriptors "+descriptors);			
			
	UtilsOpenCV.matToJson(descriptors);
	
	//UtilsOpenCV.matStore(path, descriptors);
	
	// UtilsOpenCV.matRetrieve(path, rows, cols, type);
	
}
 
Example 19
Project: StormCV   File: FeatureExtractionOp.java   View Source Code Vote up 4 votes
@Override
public List<CVParticle> execute(CVParticle particle) throws Exception {
	List<CVParticle> result = new ArrayList<CVParticle>();
	if(!(particle instanceof Frame)) return result;
	
	Frame frame = (Frame)particle;
	if(frame.getImageType().equals(Frame.NO_IMAGE)) return result;
	try{
		MatOfByte mob = new MatOfByte(frame.getImageBytes());
		Mat image = Highgui.imdecode(mob, Highgui.CV_LOAD_IMAGE_ANYCOLOR);
		
		FeatureDetector siftDetector = FeatureDetector.create(detectorType);
		MatOfKeyPoint mokp = new MatOfKeyPoint();
		siftDetector.detect(image, mokp);
		List<KeyPoint> keypoints = mokp.toList();
		
		Mat descriptors = new Mat();
		DescriptorExtractor extractor = DescriptorExtractor.create(descriptorType);
		extractor.compute(image, mokp, descriptors);
		List<Descriptor> descrList = new ArrayList<Descriptor>();
		float[] tmp = new float[1];
		for(int r=0; r<descriptors.rows(); r++){
			float[] values = new float[descriptors.cols()];
			for(int c=0; c<descriptors.cols(); c++){
				descriptors.get(r, c, tmp);
				values[c] = tmp[0];
			}
			descrList.add(new Descriptor(frame.getStreamId(), frame.getSequenceNr(), new Rectangle((int)keypoints.get(r).pt.x, (int)keypoints.get(r).pt.y, 0, 0), 0, values));
		}
		
		Feature feature = new Feature(frame.getStreamId(), frame.getSequenceNr(), featureName, 0, descrList, null);
		if(outputFrame){
			frame.getFeatures().add(feature);
			result.add(frame);
		}else{
			result.add(feature);
		}		
	}catch(Exception e){
		// catching exception at this point will prevent the sent of a fail! 
		logger.warn("Unable to extract features for frame!", e);
	}
	return result;
}
 
Example 20
Project: enchantment   File: ImageMatcher.java   View Source Code Vote up 4 votes
public static FeatureData detectFeatures(Mat mat) {
	FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
	DescriptorExtractor extractor = DescriptorExtractor
			.create(DescriptorExtractor.ORB);
	MatOfKeyPoint keypoints = new MatOfKeyPoint();
	Mat descriptors = new Mat();
	detector.detect(mat, keypoints);
	extractor.compute(mat, keypoints, descriptors);
	return new FeatureData(keypoints, descriptors);
}
 
Example 21
Project: FTC2016   File: ObjectDetection.java   View Source Code Vote up 3 votes
/**
 * Instantiate an object detector based on the FAST, BRIEF, and BRUTEFORCE_HAMMING algorithms
 */
public ObjectDetection() {
    detector = FeatureDetector.create(FeatureDetectorType.FAST.val());
    extractor = DescriptorExtractor.create(DescriptorExtractorType.BRIEF.val());
    matcher = DescriptorMatcher.create(DescriptorMatcherType.BRUTEFORCE_HAMMING.val());
}
 
Example 22
Project: FTC2016   File: ObjectDetection.java   View Source Code Vote up 3 votes
/**
 * Instantiate an object detector based on custom algorithms
 *
 * @param detector  Keypoint detection algorithm
 * @param extractor Keypoint descriptor extractor
 * @param matcher   Descriptor matcher
 */
public ObjectDetection(FeatureDetectorType detector, DescriptorExtractorType extractor, DescriptorMatcherType matcher) {
    this.detector = FeatureDetector.create(detector.val());
    this.extractor = DescriptorExtractor.create(extractor.val());
    this.matcher = DescriptorMatcher.create(matcher.val());
}
 
Example 23
Project: RobotIGS   File: ObjectDetection.java   View Source Code Vote up 2 votes
/**
 * Instantiate an object detector based on custom algorithms
 *
 * @param detector  Keypoint detection algorithm
 * @param extractor Keypoint descriptor extractor
 * @param matcher   Descriptor matcher
 */
public ObjectDetection(FeatureDetectorType detector, DescriptorExtractorType extractor, DescriptorMatcherType matcher) {
    this.detector = FeatureDetector.create(detector.val());
    this.extractor = DescriptorExtractor.create(extractor.val());
    this.matcher = DescriptorMatcher.create(matcher.val());
}
 
Example 24
Project: 2016-FTC   File: ObjectDetection.java   View Source Code Vote up 2 votes
/**
 * Instantiate an object detector based on custom algorithms
 *
 * @param detector  Keypoint detection algorithm
 * @param extractor Keypoint descriptor extractor
 * @param matcher   Descriptor matcher
 */
public ObjectDetection(FeatureDetectorType detector, DescriptorExtractorType extractor, DescriptorMatcherType matcher) {
    this.detector = FeatureDetector.create(detector.val());
    this.extractor = DescriptorExtractor.create(extractor.val());
    this.matcher = DescriptorMatcher.create(matcher.val());
}
 
Example 25
Project: FTCVision   File: ObjectDetection.java   View Source Code Vote up 2 votes
/**
 * Instantiate an object detector based on custom algorithms
 *
 * @param detector  Keypoint detection algorithm
 * @param extractor Keypoint descriptor extractor
 * @param matcher   Descriptor matcher
 */
public ObjectDetection(FeatureDetectorType detector, DescriptorExtractorType extractor, DescriptorMatcherType matcher) {
    this.detector = FeatureDetector.create(detector.val());
    this.extractor = DescriptorExtractor.create(extractor.val());
    this.matcher = DescriptorMatcher.create(matcher.val());
}