Items with no label
3335 Discussions

Realsense D415 OpenCV face detection error

KJang1
Beginner
3,259 Views

Hi

I am new to Realsense. I am trying to use Realsense with openCV by C++.

I already tried it. However, Something does not work pretty well.

By openCV I made Realsense streaming with gray scale. However, when the

Debug reach to CascadeClassifier, which is just like

face_cascade(frame_gray, faces,1.1,5,0|CASCADE_SCALE_IMAGE,Size(50,50));

the memory violation came out and stop debugging.

At first time, I assume that something is wrong with pointer.

Therefore, I tried changing gray scale channel, but did not gone well.

error shows like this :

예외 발생(0x00007FFD00A14008, camera_test001.exe): Microsoft C++ 예외: std::exception, 메모리 위치 0x000000642ACFCF90. 0x784 스레드가 종료되었습니다(코드: 0 (0x0))

(exception occur(0x00007FFD00A14008, camera_test001.exe): Microsoft C++ Exception: std::exception, memory location 0x000000642ACFCF90. 0x784 thread has been closed(code:0 (0x0))

and my complete code is this:

// License: Apache 2.0.See LICENSE file in root directory.

// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

# include // Include RealSense Cross Platform API

# include // Include OpenCV API

# include "opencv2/objdetect.hpp"

# include "opencv2/videoio.hpp"

# include "opencv2/highgui.hpp"

# include "opencv2/imgproc.hpp"

using namespace std;

using namespace cv;

//String face_cascade_name;

CascadeClassifier face_cascade;

void detectAndDisplay(Mat frame) {

std::vector faces;

Mat frame_gray;// (Size(640, 480));

string window_name = "Test";

//frame.convertTo(frame, CV_8UC3);

cvtColor(frame, frame, COLOR_BGR2RGB);

cvtColor(frame, frame_gray, COLOR_RGB2GRAY);

equalizeHist(frame_gray, frame_gray);

//frame_gray.convertTo(frame_gray, CV_8UC3);

if (frame.empty() || frame_gray.empty()) {

printf("error, no data\n");

}

else {

printf("nothing\n");

}

face_cascade.detectMultiScale(frame_gray, faces , 1.1, 5, 0 | CASCADE_SCALE_IMAGE, Size(50, 50));

imshow(window_name, frame_gray);

}

int main(int argc, char * argv[]) try

{

rs2::colorizer color_map;

rs2::pipeline pipe;

face_cascade.load("C:\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_default.xml");

pipe.start();

const auto window_name = "Display Image";

namedWindow(window_name, WINDOW_AUTOSIZE);

while (waitKey(1) < 0 && cvGetWindowHandle(window_name))

<...
0 Kudos
4 Replies
idata
Employee
985 Views

Hello Justin_j,

 

 

Can you please share with me the exact error code and the complete code?

 

 

This is in order for us to determinate the root cause of this issue.

 

 

Best Regards,

 

Juan N.
0 Kudos
KJang1
Beginner
985 Views

Sure! I just added my complete code.

0 Kudos
idata
Employee
985 Views

Hello,

 

 

Thanks for your update.

 

 

We have attempted to reproduce your issue and we have not been able to. We compiled your code and it worked fine.

 

 

Did you followed the instructions on https://github.com/IntelRealSense/librealsense/tree/master/wrappers/opencv to build the OpenCV samples from librealsense? Do the other samples work?

 

 

What version of Windows and Visual Studio are you using? We have tested the issue with Visual Studio 2015.

 

 

Microsoft Visual Studio Community 2015

 

Version 14.0.25431.01 Update 3

 

Microsoft .NET Framework

 

Version 4.6.01590

 

 

You can also try to reinstall your vcomp140.dll file:

 

 

Go to Microsoft website and download the Visual C++ Redistributable for Visual Studio 2015 from https://www.microsoft.com/en-ca/download/details.aspx?id=48145. You are going to want to select both 'vc_redist.x64.exe' and 'vc_redist.x86.exe' files to download. Once the files are downloaded, restart the computer as prompted.

 

 

Hope this information helps, We will be waiting for your feedback.

 

 

Best Regards,

 

Juan N.
0 Kudos
KJang1
Beginner
985 Views

Hello

Thank your for your help.

I am using

Microsoft Visual Studio Community 2017

Version 15,7.1

Microsoft .NET Framework

Version 4.7.02556

I have tried examples. Everything works except rs-dnn,rs-grabcuts-rs-latency-tool in OpenCV.

The output shows

예외발생 (0x75843F12(KernelBase.dll), rs-dnn.exe): WinRT originate error - 0xC00D36B3 : '제공된 스트림 번호가 잘못되었습니다.'

Exception occurs(0x75843F12(KernelBase.dll), rs-dnn.exe): WinRT originate error - 0xC00D36B3 : 'The stream number is wrong'

I will install Visual Studio Community 2015 and let you know the result again.

0 Kudos
Reply