001// 002// This file is auto-generated. Please don't modify it! 003// 004package org.opencv.dnn; 005 006import java.util.ArrayList; 007import java.util.List; 008import org.opencv.core.Algorithm; 009import org.opencv.core.Mat; 010import org.opencv.utils.Converters; 011 012// C++: class Layer 013/** 014 * This interface class allows to build new Layers - are building blocks of networks. 015 * 016 * Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs. 017 * Also before using the new layer into networks you must register your layer by using one of REF: dnnLayerFactory "LayerFactory" macros. 018 */ 019public class Layer extends Algorithm { 020 021 protected Layer(long addr) { super(addr); } 022 023 // internal usage only 024 public static Layer __fromPtr__(long addr) { return new Layer(addr); } 025 026 // 027 // C++: void cv::dnn::Layer::finalize(vector_Mat inputs, vector_Mat& outputs) 028 // 029 030 /** 031 * Computes and sets internal parameters according to inputs, outputs and blobs. 032 * @param outputs vector of already allocated output blobs 033 * 034 * If this method is called after network has allocated all memory for input and output blobs 035 * and before inferencing. 036 * @param inputs automatically generated 037 */ 038 public void finalize(List<Mat> inputs, List<Mat> outputs) { 039 Mat inputs_mat = Converters.vector_Mat_to_Mat(inputs); 040 Mat outputs_mat = new Mat(); 041 finalize_0(nativeObj, inputs_mat.nativeObj, outputs_mat.nativeObj); 042 Converters.Mat_to_vector_Mat(outputs_mat, outputs); 043 outputs_mat.release(); 044 } 045 046 047 // 048 // C++: void cv::dnn::Layer::run(vector_Mat inputs, vector_Mat& outputs, vector_Mat& internals) 049 // 050 051 /** 052 * Allocates layer and computes output. 053 * @deprecated This method will be removed in the future release. 054 * @param inputs automatically generated 055 * @param outputs automatically generated 056 * @param internals automatically generated 057 */ 058 @Deprecated 059 public void run(List<Mat> inputs, List<Mat> outputs, List<Mat> internals) { 060 Mat inputs_mat = Converters.vector_Mat_to_Mat(inputs); 061 Mat outputs_mat = new Mat(); 062 Mat internals_mat = Converters.vector_Mat_to_Mat(internals); 063 run_0(nativeObj, inputs_mat.nativeObj, outputs_mat.nativeObj, internals_mat.nativeObj); 064 Converters.Mat_to_vector_Mat(outputs_mat, outputs); 065 outputs_mat.release(); 066 Converters.Mat_to_vector_Mat(internals_mat, internals); 067 internals_mat.release(); 068 } 069 070 071 // 072 // C++: int cv::dnn::Layer::outputNameToIndex(String outputName) 073 // 074 075 /** 076 * Returns index of output blob in output array. 077 * SEE: inputNameToIndex() 078 * @param outputName automatically generated 079 * @return automatically generated 080 */ 081 public int outputNameToIndex(String outputName) { 082 return outputNameToIndex_0(nativeObj, outputName); 083 } 084 085 086 // 087 // C++: vector_Mat Layer::blobs 088 // 089 090 public List<Mat> get_blobs() { 091 List<Mat> retVal = new ArrayList<Mat>(); 092 Mat retValMat = new Mat(get_blobs_0(nativeObj)); 093 Converters.Mat_to_vector_Mat(retValMat, retVal); 094 return retVal; 095 } 096 097 098 // 099 // C++: void Layer::blobs 100 // 101 102 public void set_blobs(List<Mat> blobs) { 103 Mat blobs_mat = Converters.vector_Mat_to_Mat(blobs); 104 set_blobs_0(nativeObj, blobs_mat.nativeObj); 105 } 106 107 108 // 109 // C++: String Layer::name 110 // 111 112 public String get_name() { 113 return get_name_0(nativeObj); 114 } 115 116 117 // 118 // C++: String Layer::type 119 // 120 121 public String get_type() { 122 return get_type_0(nativeObj); 123 } 124 125 126 // 127 // C++: int Layer::preferableTarget 128 // 129 130 public int get_preferableTarget() { 131 return get_preferableTarget_0(nativeObj); 132 } 133 134 135 @Override 136 protected void finalize() throws Throwable { 137 delete(nativeObj); 138 } 139 140 141 142 // C++: void cv::dnn::Layer::finalize(vector_Mat inputs, vector_Mat& outputs) 143 private static native void finalize_0(long nativeObj, long inputs_mat_nativeObj, long outputs_mat_nativeObj); 144 145 // C++: void cv::dnn::Layer::run(vector_Mat inputs, vector_Mat& outputs, vector_Mat& internals) 146 private static native void run_0(long nativeObj, long inputs_mat_nativeObj, long outputs_mat_nativeObj, long internals_mat_nativeObj); 147 148 // C++: int cv::dnn::Layer::outputNameToIndex(String outputName) 149 private static native int outputNameToIndex_0(long nativeObj, String outputName); 150 151 // C++: vector_Mat Layer::blobs 152 private static native long get_blobs_0(long nativeObj); 153 154 // C++: void Layer::blobs 155 private static native void set_blobs_0(long nativeObj, long blobs_mat_nativeObj); 156 157 // C++: String Layer::name 158 private static native String get_name_0(long nativeObj); 159 160 // C++: String Layer::type 161 private static native String get_type_0(long nativeObj); 162 163 // C++: int Layer::preferableTarget 164 private static native int get_preferableTarget_0(long nativeObj); 165 166 // native support for java finalize() 167 private static native void delete(long nativeObj); 168 169}