introlab / rtabmap

RTAB-Map library and standalone application
https://introlab.github.io/rtabmap
Other
2.75k stars 783 forks source link

stereo camera example #1352

Open nesquik011 opened 10 hours ago

nesquik011 commented 10 hours ago

hello is there anyone has a C++ code as stereo example ? i want to do visalizatio and build a dense map with loop detection and icp etc the example i found says i need to pick one , so if i am using usb camera what should i do ? its not ZED , but it looks like ZED its stereo , with one stream feed and i need to use opencv first to pick the resolution and forrce it to be MJPG so how can i do that

void showUsage()
{
    printf("\nUsage:\n"
            "rtabmap-rgbd_mapping driver\n"
            "  driver       Driver number to use: 0=OpenNI-PCL, 1=OpenNI2, 2=Freenect, 3=OpenNI-CV, 4=OpenNI-CV-ASUS, 5=Freenect2, 6=ZED SDK, 7=RealSense, 8=RealSense2 9=Kinect for Azure SDK 10=MYNT EYE S\n\n");
    exit(1);
}

using namespace rtabmap;
int main(int argc, char * argv[])
{
    ULogger::setType(ULogger::kTypeConsole);
    ULogger::setLevel(ULogger::kWarning);

#ifdef RTABMAP_PYTHON
    PythonInterface python; // Make sure we initialize python in main thread
#endif

    int driver = 0;
    if(argc < 2)
    {
        showUsage();
    }
    else
    {
        driver = atoi(argv[argc-1]);
        if(driver < 0 || driver > 10)
        {
            UERROR("driver should be between 0 and 10.");
            showUsage();
        }
    }

thanks in advance

matlabbe commented 5 hours ago

Does the camera give you a side-by-side video stream in opencv? You could use this camera driver: https://github.com/introlab/rtabmap/blob/master/corelib/include/rtabmap/core/camera/CameraStereoVideo.h

You will need to calibrate the camera. If you have already the calibration, convert in the right format. Look at the yaml files in the example stereo data here: https://github.com/introlab/rtabmap/wiki/Stereo-mapping#process-a-directory-of-stereo-images

If the camera is not calibrated, you can calibrate from rtabmap main app. Go in Preferences->Source, select Stereo input then scroll down to select "Side-by-side video" driver, then click on calibrate. You can export a checkerboard from that screen and show it on a display/tv (then measure the size of the squares).