Ask Your Question
0

Opencv split(frame,std::Vector<cv::Mat>) crashed

asked 2017-12-05 02:48:22 -0600

zehra gravatar image

updated 2017-12-05 04:33:41 -0600

Hi,

I try to create dll using opencv methods for unity but I run my dll with split function ,my app crash

extern "C" void __declspec(dllexport) __stdcall  Test()
{
Mat frame;
capture >> frame;
if (frame.empty())
return;

std::vector<Mat> channels(3);

split(frame, channels);

}

I cant use Vector in split ,I try like below

extern "C" void __declspec(dllexport) __stdcall  Test()
{
Mat frame;
capture >> frame;
if (frame.empty())
return;

Mat channels[3];

split(frame, channels);

}

it works but I need to use vector version How can I solve my problem ?

please help me :(

edit retag flag offensive close merge delete

Comments

1

try: std::vector<Mat> channels; , not std::vector<Mat> channels(3);

berak gravatar imageberak ( 2017-12-05 02:53:46 -0600 )edit

Okay there are still some issues

  • In the first and second piece of code, make sure your return has an identation or just use brackets like this if (frame.empty()){ return; }. If not, your code will always hit the return and do nothing.
  • Secondly in the second piece of code there is a typo. channles should be channels.
  • Thirdly you cannot simply index a Mat element like in the second piece of code.
StevenPuttemans gravatar imageStevenPuttemans ( 2017-12-05 03:50:00 -0600 )edit

thanks berak , I tried std::vector<mat> channels but it didnt work tooo

zehra gravatar imagezehra ( 2017-12-05 04:01:26 -0600 )edit

Hi Steven, important issue is not syntax error :D I have controled possiblity which my frame is empty

zehra gravatar imagezehra ( 2017-12-05 04:03:53 -0600 )edit
1

@zehra, we cannot help you if all you can say is "did not work". we need an exact error message.

berak gravatar imageberak ( 2017-12-05 04:19:18 -0600 )edit

@berak ok it means application crashed in unity and send output_log message :

opencv_core2412.dll caused an Access Violation (0xc0000005) in module opencv_core2412.dll at 0033:ef451bd5.

zehra gravatar imagezehra ( 2017-12-05 04:23:42 -0600 )edit
1

@zehra, have a look at your linker settings, make sure to use opencv release libs only with release build, and also make sure, you use the same crt for the dll and your app.

also, which vs version do you use ? did you build the opencv libs locally ? (and why on earth outdated 2412 ?)

berak gravatar imageberak ( 2017-12-05 09:33:25 -0600 )edit

What happens when you do this:

split(frame, &channels[0]);
sjhalayka gravatar imagesjhalayka ( 2017-12-05 10:49:41 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-12-06 01:25:24 -0600

zehra gravatar image

@berak @sjhalayka thanks for help

I updated OpenCV 3.31 and it works like below :D

std::vector<mat> channels(3); split(frame, channels);

edit flag offensive delete link more

Comments

@zehra, but again, there is no point in defining the amount of channels beforehand. C++ code does not work in that way ...

StevenPuttemans gravatar imageStevenPuttemans ( 2017-12-06 04:22:36 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-12-05 02:48:22 -0600

Seen: 1,966 times

Last updated: Dec 05 '17