当前位置: 首页>>代码示例>>Java>>正文


Java DescriptorExtractor.compute方法代码示例

本文整理汇总了Java中org.opencv.features2d.DescriptorExtractor.compute方法的典型用法代码示例。如果您正苦于以下问题:Java DescriptorExtractor.compute方法的具体用法?Java DescriptorExtractor.compute怎么用?Java DescriptorExtractor.compute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opencv.features2d.DescriptorExtractor的用法示例。


在下文中一共展示了DescriptorExtractor.compute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateDescriptors

import org.opencv.features2d.DescriptorExtractor; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:sensorstorm,项目名称:StormCV,代码行数:21,代码来源:PartialMatcher.java

示例2: detectMinutiae

import org.opencv.features2d.DescriptorExtractor; //导入方法依赖的package包/类
private Mat detectMinutiae(Mat skeleton, int border) {
    HashSet<Minutiae> minutiaeSet = new HashSet<>();
    System.out.println("Detecting minutiae");
    for(int c = border; c<skeleton.cols()-border; c++){
        for(int r = border; r<skeleton.rows()-border; r++) {
            double point = skeleton.get(r, c)[0];
            if (point != 0) {  // Not black
                int cn = neighbourCount(skeleton, r, c);

                if(cn == 1)
                    minutiaeSet.add(new Minutiae(c, r, Minutiae.Type.RIDGEENDING));
                else if(cn == 3)
                    minutiaeSet.add(new Minutiae(c, r, Minutiae.Type.BIFURCATION));
            }
        }
    }

    System.out.println("filtering minutiae");
    HashSet<Minutiae> filteredMinutiae = filterMinutiae(minutiaeSet, skeleton);
    System.out.println("number of minutiae: " + filteredMinutiae.size());
    Mat result = new Mat();
    System.out.println("Drawing minutiae");
    Imgproc.cvtColor(skeleton, result, Imgproc.COLOR_GRAY2RGB);
    double[] red = {255, 0, 0};
    double[] green = {0, 255, 0};
    for (Minutiae m : filteredMinutiae) {
        double [] color;
        if (m.type == Minutiae.Type.BIFURCATION) color = green;
        else color = red;
        result.put(m.y, m.x  , color);
        result.put(m.y, m.x-1, color);
        result.put(m.y, m.x+1, color);
        result.put(m.y-1, m.x  , color);
        result.put(m.y+1, m.x  , color);
    }
    MatOfKeyPoint keypoints = new MatOfKeyPoint();
    keypoints.fromArray(minutiaeToKeyPoints(skeleton, filteredMinutiae));
    keypointsField = keypoints;
    DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
    Mat descriptors = new Mat();
    extractor.compute(skeleton, keypoints, descriptors);
    descriptorsField = descriptors;
    return result;
}
 
开发者ID:jorenham,项目名称:fingerblox,代码行数:45,代码来源:ImageProcessing.java

示例3: detectFeatures

import org.opencv.features2d.DescriptorExtractor; //导入方法依赖的package包/类
@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;
}
 
开发者ID:jorenham,项目名称:fingerblox,代码行数:35,代码来源:ImageProcessing.java

示例4: compute

import org.opencv.features2d.DescriptorExtractor; //导入方法依赖的package包/类
private static Mat compute(Mat img, MatOfKeyPoint points, DescriptorExtractor extractor) {
	// Compute descriptor
	Mat descriptor = new Mat();
	extractor.compute(img, points, descriptor);
	return descriptor;
}
 
开发者ID:DaniUPC,项目名称:near-image-replica-detection,代码行数:7,代码来源:Image.java

示例5: testMatSerialization

import org.opencv.features2d.DescriptorExtractor; //导入方法依赖的package包/类
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);
	
}
 
开发者ID:ruimarques,项目名称:OpenCV-BackProjection,代码行数:23,代码来源:BackProjectionActivity.java

示例6: execute

import org.opencv.features2d.DescriptorExtractor; //导入方法依赖的package包/类
@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;
}
 
开发者ID:sensorstorm,项目名称:StormCV,代码行数:44,代码来源:FeatureExtractionOp.java

示例7: detectFeatures

import org.opencv.features2d.DescriptorExtractor; //导入方法依赖的package包/类
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);
}
 
开发者ID:g-rauhoeft,项目名称:enchantment,代码行数:11,代码来源:ImageMatcher.java


注:本文中的org.opencv.features2d.DescriptorExtractor.compute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。