Question

I am trying to use TBB to boost the performance of a computer vision project which uses OpenCV. Here is the part in the code which gives access violation.

#include <opencv/cv.h>
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "tbb/pipeline.h"
#include "tbb/tick_count.h"
#include "tbb/task_scheduler_init.h"
#include "tbb/tbb_allocator.h"
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
    string file = "myimage.jpg";
    Mat* mats2=tbb::tbb_allocator<Mat>().allocate(100);
    for (int i = 0 ; i < 100 ; ++i)
    {
        mats2[i]=imread(file);         <===== Access Violation
        imshow("temp",mats3[i]);
        waitKey(1);
    }
}

Why is this an Access Violation? Mats2 is not 0 and is definitely assigned to an address in memory. I know other functions from this link that I can use but I want to know what happens in tbb_allocator that leads to this error. The code doesn't give error if used with malloc or scalable_malloc.

Was it helpful?

Solution

As seems, it is a C-C++ issue. New and Delete worked but still scalable allocation gives access violation. Sound like the only option for OpenCV users right now.

OTHER TIPS

i dont know if this might help

imread(filename)

is just an attempts to infer the format of the file from its content. Just check how you are required to use this call .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top