001//
002// This file is auto-generated. Please don't modify it!
003//
004package org.opencv.video;
005
006import org.opencv.core.Mat;
007import org.opencv.core.Rect;
008
009// C++: class Tracker
010/**
011 * Base abstract class for the long-term tracker
012 */
013public class Tracker {
014
015    protected final long nativeObj;
016    protected Tracker(long addr) { nativeObj = addr; }
017
018    public long getNativeObjAddr() { return nativeObj; }
019
020    // internal usage only
021    public static Tracker __fromPtr__(long addr) { return new Tracker(addr); }
022
023    //
024    // C++:  void cv::Tracker::init(Mat image, Rect boundingBox)
025    //
026
027    /**
028     * Initialize the tracker with a known bounding box that surrounded the target
029     *     @param image The initial frame
030     *     @param boundingBox The initial bounding box
031     */
032    public void init(Mat image, Rect boundingBox) {
033        init_0(nativeObj, image.nativeObj, boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height);
034    }
035
036
037    //
038    // C++:  bool cv::Tracker::update(Mat image, Rect& boundingBox)
039    //
040
041    /**
042     * Update the tracker, find the new most likely bounding box for the target
043     *     @param image The current frame
044     *     @param boundingBox The bounding box that represent the new target location, if true was returned, not
045     *     modified otherwise
046     *
047     *     @return True means that target was located and false means that tracker cannot locate target in
048     *     current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed
049     *     missing from the frame (say, out of sight)
050     */
051    public boolean update(Mat image, Rect boundingBox) {
052        double[] boundingBox_out = new double[4];
053        boolean retVal = update_0(nativeObj, image.nativeObj, boundingBox_out);
054        if(boundingBox!=null){ boundingBox.x = (int)boundingBox_out[0]; boundingBox.y = (int)boundingBox_out[1]; boundingBox.width = (int)boundingBox_out[2]; boundingBox.height = (int)boundingBox_out[3]; } 
055        return retVal;
056    }
057
058
059    @Override
060    protected void finalize() throws Throwable {
061        delete(nativeObj);
062    }
063
064
065
066    // C++:  void cv::Tracker::init(Mat image, Rect boundingBox)
067    private static native void init_0(long nativeObj, long image_nativeObj, int boundingBox_x, int boundingBox_y, int boundingBox_width, int boundingBox_height);
068
069    // C++:  bool cv::Tracker::update(Mat image, Rect& boundingBox)
070    private static native boolean update_0(long nativeObj, long image_nativeObj, double[] boundingBox_out);
071
072    // native support for java finalize()
073    private static native void delete(long nativeObj);
074
075}