001// 002// This file is auto-generated. Please don't modify it! 003// 004package org.opencv.features2d; 005 006import java.util.ArrayList; 007import java.util.List; 008import org.opencv.core.Mat; 009import org.opencv.utils.Converters; 010 011// C++: class BOWTrainer 012/** 013 * Abstract base class for training the *bag of visual words* vocabulary from a set of descriptors. 014 * 015 * For details, see, for example, *Visual Categorization with Bags of Keypoints* by Gabriella Csurka, 016 * Christopher R. Dance, Lixin Fan, Jutta Willamowski, Cedric Bray, 2004. : 017 */ 018public class BOWTrainer { 019 020 protected final long nativeObj; 021 protected BOWTrainer(long addr) { nativeObj = addr; } 022 023 public long getNativeObjAddr() { return nativeObj; } 024 025 // internal usage only 026 public static BOWTrainer __fromPtr__(long addr) { return new BOWTrainer(addr); } 027 028 // 029 // C++: void cv::BOWTrainer::add(Mat descriptors) 030 // 031 032 /** 033 * Adds descriptors to a training set. 034 * 035 * @param descriptors Descriptors to add to a training set. Each row of the descriptors matrix is a 036 * descriptor. 037 * 038 * The training set is clustered using clustermethod to construct the vocabulary. 039 */ 040 public void add(Mat descriptors) { 041 add_0(nativeObj, descriptors.nativeObj); 042 } 043 044 045 // 046 // C++: vector_Mat cv::BOWTrainer::getDescriptors() 047 // 048 049 /** 050 * Returns a training set of descriptors. 051 * @return automatically generated 052 */ 053 public List<Mat> getDescriptors() { 054 List<Mat> retVal = new ArrayList<Mat>(); 055 Mat retValMat = new Mat(getDescriptors_0(nativeObj)); 056 Converters.Mat_to_vector_Mat(retValMat, retVal); 057 return retVal; 058 } 059 060 061 // 062 // C++: int cv::BOWTrainer::descriptorsCount() 063 // 064 065 /** 066 * Returns the count of all descriptors stored in the training set. 067 * @return automatically generated 068 */ 069 public int descriptorsCount() { 070 return descriptorsCount_0(nativeObj); 071 } 072 073 074 // 075 // C++: void cv::BOWTrainer::clear() 076 // 077 078 public void clear() { 079 clear_0(nativeObj); 080 } 081 082 083 // 084 // C++: Mat cv::BOWTrainer::cluster() 085 // 086 087 public Mat cluster() { 088 return new Mat(cluster_0(nativeObj)); 089 } 090 091 092 // 093 // C++: Mat cv::BOWTrainer::cluster(Mat descriptors) 094 // 095 096 /** 097 * Clusters train descriptors. 098 * 099 * @param descriptors Descriptors to cluster. Each row of the descriptors matrix is a descriptor. 100 * Descriptors are not added to the inner train descriptor set. 101 * 102 * The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first 103 * variant of the method, train descriptors stored in the object are clustered. In the second variant, 104 * input descriptors are clustered. 105 * @return automatically generated 106 */ 107 public Mat cluster(Mat descriptors) { 108 return new Mat(cluster_1(nativeObj, descriptors.nativeObj)); 109 } 110 111 112 @Override 113 protected void finalize() throws Throwable { 114 delete(nativeObj); 115 } 116 117 118 119 // C++: void cv::BOWTrainer::add(Mat descriptors) 120 private static native void add_0(long nativeObj, long descriptors_nativeObj); 121 122 // C++: vector_Mat cv::BOWTrainer::getDescriptors() 123 private static native long getDescriptors_0(long nativeObj); 124 125 // C++: int cv::BOWTrainer::descriptorsCount() 126 private static native int descriptorsCount_0(long nativeObj); 127 128 // C++: void cv::BOWTrainer::clear() 129 private static native void clear_0(long nativeObj); 130 131 // C++: Mat cv::BOWTrainer::cluster() 132 private static native long cluster_0(long nativeObj); 133 134 // C++: Mat cv::BOWTrainer::cluster(Mat descriptors) 135 private static native long cluster_1(long nativeObj, long descriptors_nativeObj); 136 137 // native support for java finalize() 138 private static native void delete(long nativeObj); 139 140}