001//
002// This file is auto-generated. Please don't modify it!
003//
004package org.opencv.objdetect;
005
006import java.util.ArrayList;
007import java.util.List;
008import org.opencv.core.Mat;
009import org.opencv.core.MatOfInt;
010import org.opencv.core.MatOfPoint3f;
011import org.opencv.core.Point3;
012import org.opencv.core.Size;
013import org.opencv.objdetect.Dictionary;
014import org.opencv.utils.Converters;
015
016// C++: class Board
017/**
018 * Board of ArUco markers
019 *
020 * A board is a set of markers in the 3D space with a common coordinate system.
021 * The common form of a board of marker is a planar (2D) board, however any 3D layout can be used.
022 * A Board object is composed by:
023 * - The object points of the marker corners, i.e. their coordinates respect to the board system.
024 * - The dictionary which indicates the type of markers of the board
025 * - The identifier of all the markers in the board.
026 */
027public class Board {
028
029    protected final long nativeObj;
030    protected Board(long addr) { nativeObj = addr; }
031
032    public long getNativeObjAddr() { return nativeObj; }
033
034    // internal usage only
035    public static Board __fromPtr__(long addr) { return new Board(addr); }
036
037    //
038    // C++:   cv::aruco::Board::Board(vector_Mat objPoints, Dictionary dictionary, Mat ids)
039    //
040
041    /**
042     * Common Board constructor
043     *
044     * @param objPoints array of object points of all the marker corners in the board
045     * @param dictionary the dictionary of markers employed for this board
046     * @param ids vector of the identifiers of the markers in the board
047     */
048    public Board(List<Mat> objPoints, Dictionary dictionary, Mat ids) {
049        Mat objPoints_mat = Converters.vector_Mat_to_Mat(objPoints);
050        nativeObj = Board_0(objPoints_mat.nativeObj, dictionary.nativeObj, ids.nativeObj);
051    }
052
053
054    //
055    // C++:  Dictionary cv::aruco::Board::getDictionary()
056    //
057
058    /**
059     * return the Dictionary of markers employed for this board
060     * @return automatically generated
061     */
062    public Dictionary getDictionary() {
063        return new Dictionary(getDictionary_0(nativeObj));
064    }
065
066
067    //
068    // C++:  vector_vector_Point3f cv::aruco::Board::getObjPoints()
069    //
070
071    /**
072     * return array of object points of all the marker corners in the board.
073     *
074     * Each marker include its 4 corners in this order:
075     * -   objPoints[i][0] - left-top point of i-th marker
076     * -   objPoints[i][1] - right-top point of i-th marker
077     * -   objPoints[i][2] - right-bottom point of i-th marker
078     * -   objPoints[i][3] - left-bottom point of i-th marker
079     *
080     * Markers are placed in a certain order - row by row, left to right in every row. For M markers, the size is Mx4.
081     * @return automatically generated
082     */
083    public List<MatOfPoint3f> getObjPoints() {
084        List<MatOfPoint3f> retVal = new ArrayList<MatOfPoint3f>();
085        Mat retValMat = new Mat(getObjPoints_0(nativeObj));
086        Converters.Mat_to_vector_vector_Point3f(retValMat, retVal);
087        return retVal;
088    }
089
090
091    //
092    // C++:  vector_int cv::aruco::Board::getIds()
093    //
094
095    /**
096     * vector of the identifiers of the markers in the board (should be the same size as objPoints)
097     * @return vector of the identifiers of the markers
098     */
099    public MatOfInt getIds() {
100        return MatOfInt.fromNativeAddr(getIds_0(nativeObj));
101    }
102
103
104    //
105    // C++:  Point3f cv::aruco::Board::getRightBottomCorner()
106    //
107
108    /**
109     * get coordinate of the bottom right corner of the board, is set when calling the function create()
110     * @return automatically generated
111     */
112    public Point3 getRightBottomCorner() {
113        return new Point3(getRightBottomCorner_0(nativeObj));
114    }
115
116
117    //
118    // C++:  void cv::aruco::Board::matchImagePoints(vector_Mat detectedCorners, Mat detectedIds, Mat& objPoints, Mat& imgPoints)
119    //
120
121    /**
122     * Given a board configuration and a set of detected markers, returns the corresponding
123     * image points and object points, can be used in solvePnP()
124     *
125     * @param detectedCorners List of detected marker corners of the board.
126     * For cv::Board and cv::GridBoard the method expects std::vector&lt;std::vector&lt;Point2f&gt;&gt; or std::vector&lt;Mat&gt; with Aruco marker corners.
127     * For cv::CharucoBoard the method expects std::vector&lt;Point2f&gt; or Mat with ChAruco corners (chess board corners matched with Aruco markers).
128     *
129     * @param detectedIds List of identifiers for each marker or charuco corner.
130     * For any Board class the method expects std::vector&lt;int&gt; or Mat.
131     *
132     * @param objPoints Vector of marker points in the board coordinate space.
133     * For any Board class the method expects std::vector&lt;cv::Point3f&gt; objectPoints or cv::Mat
134     *
135     * @param imgPoints Vector of marker points in the image coordinate space.
136     * For any Board class the method expects std::vector&lt;cv::Point2f&gt; objectPoints or cv::Mat
137     *
138     * SEE: solvePnP
139     */
140    public void matchImagePoints(List<Mat> detectedCorners, Mat detectedIds, Mat objPoints, Mat imgPoints) {
141        Mat detectedCorners_mat = Converters.vector_Mat_to_Mat(detectedCorners);
142        matchImagePoints_0(nativeObj, detectedCorners_mat.nativeObj, detectedIds.nativeObj, objPoints.nativeObj, imgPoints.nativeObj);
143    }
144
145
146    //
147    // C++:  void cv::aruco::Board::generateImage(Size outSize, Mat& img, int marginSize = 0, int borderBits = 1)
148    //
149
150    /**
151     * Draw a planar board
152     *
153     * @param outSize size of the output image in pixels.
154     * @param img output image with the board. The size of this image will be outSize
155     * and the board will be on the center, keeping the board proportions.
156     * @param marginSize minimum margins (in pixels) of the board in the output image
157     * @param borderBits width of the marker borders.
158     *
159     * This function return the image of the board, ready to be printed.
160     */
161    public void generateImage(Size outSize, Mat img, int marginSize, int borderBits) {
162        generateImage_0(nativeObj, outSize.width, outSize.height, img.nativeObj, marginSize, borderBits);
163    }
164
165    /**
166     * Draw a planar board
167     *
168     * @param outSize size of the output image in pixels.
169     * @param img output image with the board. The size of this image will be outSize
170     * and the board will be on the center, keeping the board proportions.
171     * @param marginSize minimum margins (in pixels) of the board in the output image
172     *
173     * This function return the image of the board, ready to be printed.
174     */
175    public void generateImage(Size outSize, Mat img, int marginSize) {
176        generateImage_1(nativeObj, outSize.width, outSize.height, img.nativeObj, marginSize);
177    }
178
179    /**
180     * Draw a planar board
181     *
182     * @param outSize size of the output image in pixels.
183     * @param img output image with the board. The size of this image will be outSize
184     * and the board will be on the center, keeping the board proportions.
185     *
186     * This function return the image of the board, ready to be printed.
187     */
188    public void generateImage(Size outSize, Mat img) {
189        generateImage_2(nativeObj, outSize.width, outSize.height, img.nativeObj);
190    }
191
192
193    @Override
194    protected void finalize() throws Throwable {
195        delete(nativeObj);
196    }
197
198
199
200    // C++:   cv::aruco::Board::Board(vector_Mat objPoints, Dictionary dictionary, Mat ids)
201    private static native long Board_0(long objPoints_mat_nativeObj, long dictionary_nativeObj, long ids_nativeObj);
202
203    // C++:  Dictionary cv::aruco::Board::getDictionary()
204    private static native long getDictionary_0(long nativeObj);
205
206    // C++:  vector_vector_Point3f cv::aruco::Board::getObjPoints()
207    private static native long getObjPoints_0(long nativeObj);
208
209    // C++:  vector_int cv::aruco::Board::getIds()
210    private static native long getIds_0(long nativeObj);
211
212    // C++:  Point3f cv::aruco::Board::getRightBottomCorner()
213    private static native double[] getRightBottomCorner_0(long nativeObj);
214
215    // C++:  void cv::aruco::Board::matchImagePoints(vector_Mat detectedCorners, Mat detectedIds, Mat& objPoints, Mat& imgPoints)
216    private static native void matchImagePoints_0(long nativeObj, long detectedCorners_mat_nativeObj, long detectedIds_nativeObj, long objPoints_nativeObj, long imgPoints_nativeObj);
217
218    // C++:  void cv::aruco::Board::generateImage(Size outSize, Mat& img, int marginSize = 0, int borderBits = 1)
219    private static native void generateImage_0(long nativeObj, double outSize_width, double outSize_height, long img_nativeObj, int marginSize, int borderBits);
220    private static native void generateImage_1(long nativeObj, double outSize_width, double outSize_height, long img_nativeObj, int marginSize);
221    private static native void generateImage_2(long nativeObj, double outSize_width, double outSize_height, long img_nativeObj);
222
223    // native support for java finalize()
224    private static native void delete(long nativeObj);
225
226}