Items with no label
3335 Discussions

Process Memory Increasing When Capturing Multiple Depth Frames - Intel Realsense D415 Camera [Visual C++]

KChow4
Beginner
960 Views

I am using a Intel RealSense D415 Camera on Visual Studio 2019 using Visual C++.

 

I was experimenting with taking multiple depth frames across a period of time using a large for-loop (150+ instances); as I am experimenting with taking depth measurements of things moving underneath a moving conveyor belt. However, as I was doing this, I noticed that the Process Memory graph from Visual Studio was going up at an alarmingly fast rate:

 

ProcessMemoryIncrease.PNG

 

 

This is the code that I have been using:

#pragma once //Standard include libraries #include <iostream> #include <fstream> #include <Windows.h> #include <string.h>   //Realsense Include Libraries #include <rs.hpp> // Include RealSense Cross Platform API   //Namespace declarations using namespace std; using namespace rs2;   int main() {   rs2::frameset data; rs2::pipeline pipe;   rs2::config cfg; cfg.enable_stream(RS2_STREAM_DEPTH, 848, 480, RS2_FORMAT_Z16, 30);   for (int i = 0; i < 150; i++) {   cout << "Trial Number: " << i << endl;   pipe.start(cfg);   for (int i = 0; i < 5; i++) { data = pipe.wait_for_frames(); }   rs2::depth_frame dframe = data.get_depth_frame();   pipe.stop();   }   return 0; }

I have 3 questions about this:

(1) Is there anything about the code I'm using that is causing this increase in the Process Memory?

(2) Are there any additional destructors that I need to explicitly call when using the pipes in such a way?

(3) Are the cameras able to be used in the way that I am using them right now?

 

Any help will be greatly appreciated!

Thanks in advance!

0 Kudos
1 Solution
MartyG
Honored Contributor III
614 Views

My recollection of For loop programming is that once a loop begins, it keeps checking until the specified number of cycles has been completed. Until then, the program cannot exit the loop and execute any instructions below that loop (the rs2::depth_frame dframe and pipe.stop() instructions in this case).

 

The first thing I would try is taking the pipe.start(cfg); instruction out of the For loop and putting it directly below the cfg.enable_stream line. The current script suggests to me that it would try to call pipe.start every single time the For loop is checked (up to 150 times), when you should only need to start the pipeline once.

 

*****

 

BTW, I should mention that the RealSense forum has now moved to a new location if you have new questions in future. Thanks!

 

https://support.intelrealsense.com/hc/en-us/community/topics

View solution in original post

2 Replies
MartyG
Honored Contributor III
615 Views

My recollection of For loop programming is that once a loop begins, it keeps checking until the specified number of cycles has been completed. Until then, the program cannot exit the loop and execute any instructions below that loop (the rs2::depth_frame dframe and pipe.stop() instructions in this case).

 

The first thing I would try is taking the pipe.start(cfg); instruction out of the For loop and putting it directly below the cfg.enable_stream line. The current script suggests to me that it would try to call pipe.start every single time the For loop is checked (up to 150 times), when you should only need to start the pipeline once.

 

*****

 

BTW, I should mention that the RealSense forum has now moved to a new location if you have new questions in future. Thanks!

 

https://support.intelrealsense.com/hc/en-us/community/topics

KChow4
Beginner
614 Views

Thanks!

 

I gave it a go and it appears to be working.

 

Also thanks for letting me know about the new forum location, I will check it out.

0 Kudos
Reply