Hi all,
I have a c++ project existing out of more than 6 header + code files. Initially the project was built around an Intel RealSense camera, but I am trying to convert it to use the OAK-D-PoE and depthai-core. For the project I need the Depth and Color camera.
Reading the pipeline, displaying both images and processing the data within the images works fine when running the code within main(). Yet when I use a std::shared_ptr<dai:: DataOutputQueue> (or other dai datatypes) as a method-argument for a method in another (.cpp) code file it returns a segmentation error, as shown below.
Stack trace (most recent call last):
#5 Object "./Malum", at 0x557f604067, in
#4 Object "/lib/aarch64-linux-gnu/libc.so.6" , at 0x7f813226df, in __libc_start_main
#3 Object "./Malum", at 0x557f603237, in
#2 Object "./Malum", at 0x557f61c64b, in
#1 Object "./Malum", at 0x557f61b8db, in
#0 Object "./Malum", at 0x557f61afc7c, in
Segmentation fault (Address not mapped to object [0xf8])
Segmentation fault (core dumped)
Is it possible to use dai datatypes as method-arguments for methods in another code file?
example:
main():
#include "depthai/depthai.hpp"
#include "utility.hpp"
int main(){
dai::Pipeline pipeline;
auto monoLeft = pipeline.create<dai::node::MonoCamera>();
auto monoRight = pipeline.create<dai::node::MonoCamera>();
auto stereo = pipeline.create<dai::node::StereoDepth>();
auto spatialDataCalculator = pipeline.create<dai::node::SpatialLocationCalculator>();
//further setup for the camera
dai::Device device(pipeline, dai::UsbSpeed::SUPER);
auto depthQueue = device.getOutputQueue("depth", 8, false);
auto spatialCalcQueue = device.getOutputQueue("spatialData", 8, false);
while(true){
auto inDepth = depthQueue->get<dai::imgFrame();
cv::Mat depthFrame = inDepth->getFrame();
Camera.measure(depthFrame, spatialCalcQueue);
//Rest of code
}
}
in Camera.cpp:
void Camera::measure (cv::Mat depthFrame, std::shared_ptr<dai::DataOutputQueue> spatialCalcQueue){
//The following line causes segmentation fault
std::vector<dai::SpatialLocations> spatialData = spatialCalcQueue->get<dai::SpatialLocationCalculatorData>()->getSpatialLocations();
for(dai::SpatialLocations depthData : spatialData){
//Code to extract data from depth frame
}
//More code
}