Problems with object tracking

Hey all,

after successfully building OpenCV with contrib I ran into an error when trying to initialize a tracker. A smal example:

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.highgui.HighGui;
import org.opencv.imgproc.Imgproc;
import org.opencv.tracking.TrackerCSRT;
import org.opencv.tracking.TrackerKCF;
import org.opencv.videoio.VideoCapture;

public class TrackTest {

    static {System.loadLibrary(Core.NATIVE_LIBRARY_NAME);}

    public static void main(String args[]) {

        Rect roi;
        Mat frame = new Mat();
        // create a tracker object
        Tracker tracker = TrackerCSRT.create();
        // set input video
        VideoCapture capture = new VideoCapture(0);;
        // get bounding box
        roi= new Rect(310,230,20,20);

        // initialize the tracker


            Imgproc.rectangle(frame,roi,new Scalar(255,0,0));





When running the program i recive the following error massage:

Exception in thread “main” java.lang.Exception: unknown exception
at Method)
at View.TrackTest.main(

Maybe someone has an idea whats wrong. I also tried to build a try catch block but i could not retrieve anymore usefull information.

opencv version ?

can you put a


before trying to initialize the tracker ?

1 Like

My opencv Version is 4.5.2

The Output of the println comand is:

Mat [ 480*640*CV_8UC3, isCont=true, isSubmat=false, nativeObj=0x188b4ab50f0, dataAddr=0x188bbcf5980 ]
1 Like