001// 002// This file is auto-generated. Please don't modify it! 003// 004package org.opencv.dnn; 005 006import org.opencv.core.Mat; 007import org.opencv.dnn.ClassificationModel; 008import org.opencv.dnn.Model; 009import org.opencv.dnn.Net; 010 011// C++: class ClassificationModel 012/** 013 * This class represents high-level API for classification models. 014 * 015 * ClassificationModel allows to set params for preprocessing input image. 016 * ClassificationModel creates net from file with trained weights and config, 017 * sets preprocessing input, runs forward pass and return top-1 prediction. 018 */ 019public class ClassificationModel extends Model { 020 021 protected ClassificationModel(long addr) { super(addr); } 022 023 // internal usage only 024 public static ClassificationModel __fromPtr__(long addr) { return new ClassificationModel(addr); } 025 026 // 027 // C++: cv::dnn::ClassificationModel::ClassificationModel(String model, String config = "") 028 // 029 030 /** 031 * Create classification model from network represented in one of the supported formats. 032 * An order of {@code model} and {@code config} arguments does not matter. 033 * @param model Binary file contains trained weights. 034 * @param config Text file contains network configuration. 035 */ 036 public ClassificationModel(String model, String config) { 037 super(ClassificationModel_0(model, config)); 038 } 039 040 /** 041 * Create classification model from network represented in one of the supported formats. 042 * An order of {@code model} and {@code config} arguments does not matter. 043 * @param model Binary file contains trained weights. 044 */ 045 public ClassificationModel(String model) { 046 super(ClassificationModel_1(model)); 047 } 048 049 050 // 051 // C++: cv::dnn::ClassificationModel::ClassificationModel(Net network) 052 // 053 054 /** 055 * Create model from deep learning network. 056 * @param network Net object. 057 */ 058 public ClassificationModel(Net network) { 059 super(ClassificationModel_2(network.nativeObj)); 060 } 061 062 063 // 064 // C++: ClassificationModel cv::dnn::ClassificationModel::setEnableSoftmaxPostProcessing(bool enable) 065 // 066 067 /** 068 * Set enable/disable softmax post processing option. 069 * 070 * If this option is true, softmax is applied after forward inference within the classify() function 071 * to convert the confidences range to [0.0-1.0]. 072 * This function allows you to toggle this behavior. 073 * Please turn true when not contain softmax layer in model. 074 * @param enable Set enable softmax post processing within the classify() function. 075 * @return automatically generated 076 */ 077 public ClassificationModel setEnableSoftmaxPostProcessing(boolean enable) { 078 return new ClassificationModel(setEnableSoftmaxPostProcessing_0(nativeObj, enable)); 079 } 080 081 082 // 083 // C++: bool cv::dnn::ClassificationModel::getEnableSoftmaxPostProcessing() 084 // 085 086 /** 087 * Get enable/disable softmax post processing option. 088 * 089 * This option defaults to false, softmax post processing is not applied within the classify() function. 090 * @return automatically generated 091 */ 092 public boolean getEnableSoftmaxPostProcessing() { 093 return getEnableSoftmaxPostProcessing_0(nativeObj); 094 } 095 096 097 // 098 // C++: void cv::dnn::ClassificationModel::classify(Mat frame, int& classId, float& conf) 099 // 100 101 public void classify(Mat frame, int[] classId, float[] conf) { 102 double[] classId_out = new double[1]; 103 double[] conf_out = new double[1]; 104 classify_0(nativeObj, frame.nativeObj, classId_out, conf_out); 105 if(classId!=null) classId[0] = (int)classId_out[0]; 106 if(conf!=null) conf[0] = (float)conf_out[0]; 107 } 108 109 110 @Override 111 protected void finalize() throws Throwable { 112 delete(nativeObj); 113 } 114 115 116 117 // C++: cv::dnn::ClassificationModel::ClassificationModel(String model, String config = "") 118 private static native long ClassificationModel_0(String model, String config); 119 private static native long ClassificationModel_1(String model); 120 121 // C++: cv::dnn::ClassificationModel::ClassificationModel(Net network) 122 private static native long ClassificationModel_2(long network_nativeObj); 123 124 // C++: ClassificationModel cv::dnn::ClassificationModel::setEnableSoftmaxPostProcessing(bool enable) 125 private static native long setEnableSoftmaxPostProcessing_0(long nativeObj, boolean enable); 126 127 // C++: bool cv::dnn::ClassificationModel::getEnableSoftmaxPostProcessing() 128 private static native boolean getEnableSoftmaxPostProcessing_0(long nativeObj); 129 130 // C++: void cv::dnn::ClassificationModel::classify(Mat frame, int& classId, float& conf) 131 private static native void classify_0(long nativeObj, long frame_nativeObj, double[] classId_out, double[] conf_out); 132 133 // native support for java finalize() 134 private static native void delete(long nativeObj); 135 136}