Interesting ONNX Error when trying to set Rect using KeyPoints variables

Was working on trying to processes a video, locate a circle in said video and then track the circle in the video. The locating works great at pressent point but I ran into an interesting error while trying to convert from KeyPoints (used blob detector) to Rect for the tracker. The error seems to be in how I am passing through the values to the Rect.

Error:

OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.5.4) Error: Bad argument (Can't read ONNX file: dasiamrpn_model.onnx) in ONNXImporter, file D:\Visual_Studio\opencv\src\opencv\modules\dnn\src\onnx\onnx_importer.cpp, line 198
The terminal process "C:\...\bash.exe '-l', '-c', 'g++.exe -o "E:\...\Test"/bin/main.exe -I "E:\...\Test"/headers -I "D:/.../include" -ggdb "E:\...\Test"/source/*.cpp "D:/.../install/lib/**.a" && "E:\...\Test"/bin/main.exe'" terminated with exit code: 3.

Code:

#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include <opencv2/core.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/video/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
#include <cstring>

using namespace cv;
using namespace std;

int main()
{

    // Read image
    Mat im = imread("snip.png", IMREAD_GRAYSCALE);
    Rect roi;
    Mat frame;

    // Open video
    string video = "testV.mp4";
    VideoCapture cap(video);
    if (!cap.isOpened())
    {
        cout << "we ain't happy\n";
        return 0;
    }
    // take first frame from video and convert into binary colors
    cap >> frame;
    cvtColor(frame, frame, COLOR_BGR2GRAY);
    threshold(frame, frame, 100, 255, THRESH_BINARY);

    // Setup SimpleBlobDetector parameters.
    SimpleBlobDetector::Params params;

    // Change thresholds
    params.minThreshold = 0;
    params.maxThreshold = 255;

    params.filterByColor = 255;
    params.minDistBetweenBlobs = 0;

    // Filter by Area.
    params.filterByArea = false;
    params.minArea = 1000;
    // params.maxArea = 800;

    // Filter by Circularity
    params.filterByCircularity = false;
    params.minCircularity = 0.5;
    params.maxCircularity = 0.7;

    // Filter by Convexity
    params.filterByConvexity = false;
    params.minConvexity = .7;

    // Filter by Inertia
    params.filterByInertia = false;
    params.minInertiaRatio = 0.4;

    // Set up detector with params
    Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);

    // Detect blobs.
    vector<KeyPoint> keypoints;
    detector->detect(frame, keypoints);

    // Draw detected blobs as red circles.
    // DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
    Mat im_with_keypoints;
    drawKeypoints(frame, keypoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );
    
    // Setting the roi for tracking
    roi.width == keypoints[0].size;
    roi.height == keypoints[0].size;
    roi.x == keypoints[0].pt.y;
    roi.y == keypoints[0].pt.x;
    
    // Create a tracker object
    Ptr<Tracker> tracker = TrackerDaSiamRPN::create();

    // Run tracker
    printf("Start the tracking process, press ESC to quit.\n");
    for (;;)
    {
        // get frame from the video
        cap >> frame;
        // stop the program if no more images
        if (frame.rows == 0 || frame.cols == 0)
            break;
        // update the tracking result
        tracker->update(frame, roi);
        // draw the tracked object
        rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);
        // show image with the tracked object
        imshow("tracker", frame);
        //quit on ESC button
        if (waitKey(1) == 27)
            break;
    }


    // Show blobs
    imshow("keypoints", im_with_keypoints);
    waitKey(0);

}

fixed the issue by changing the TrackMIL, that aside I still get an error code termination that I don’t know why…

Start the tracking process, press ESC to quit.
The terminal process "C:....\bash.exe '-l', '-c', 'g++.exe -o "E:\....\Test"/bin/main.exe -I "E:\...\Test"/headers -I "D:/V.../include" -ggdb "E:\...\Test"/source/*.cpp "D:/Visual_Studio/opencv/install/lib/**.a" && "E:\..../bin/main.exe'" terminated with exit code: 2816.

According to my debuger, it fails on tracker->update(...) with a segmentation fault

not really astonishing, given how you try (and fail !) to create the roi:

(do you spot the problem ?)

to use this tracker, you have to download the dasiamrpn_model(s), and add the pathes to the Params structure