8 Replies Latest reply on Jun 14, 2018 10:13 AM by tuantuan91

    use opencv to access the bottom camera error

    tuantuan91

      Hi chillaxintel_corp

       

      Sorry to disturb you.

      I just want to test a code of visual odometry algorithm by using the bottom camera(use opencv cap class).

      but when I run the rode there will occur an error like this:

      highgui error:libv4l unable to ioctl s_fmt

       

      here is the code I wrote:

      void BenchmarkNode::runFromFolder()

      {

       

       

          cv::VideoCapture cap(1);  // open the default camera

       

       

          if (!cap.isOpened())  // check if we succeeded

              return ;

       

       

          int img_id = 0;

          for (;;) {

       

       

              cv::Mat image;

              cap.read(image);  // get a new frame from camera

       

       

              assert(!image.empty());

              img_id++;

       

       

              cv::imshow("origin_image", image);

              if (cv::waitKey(1) >= 0) break;

              if(img_id < 100) continue;

       

       

              cv::cvtColor(image,image,CV_BGR2GRAY);

              /*

              cv::Mat unimg;

              cam_pinhole_->undistortImage(image,unimg);

              vo_->addImage(unimg, 0.01*img_id);

               */

              vo_->addImage(image, 0.01*img_id);

       

       

              // display tracking quality

              if(vo_->lastFrame() != NULL)

              {

                  std::cout << "Frame-Id: " << vo_->lastFrame()->id_ << " \t"

                            << "#Features: " << vo_->lastNumObservations() << " \n";

                  //<< "Proc. Time: " << vo_->lastProcessingTime()*1000 << "ms \n";

                  std::cout<<"Frame pose: "<< vo_->lastFrame()->T_f_w_ <<std::endl;

       

       

              }

       

       

          }

       

       

          cap.release();

          return;

       

      Do anyone know how to use the cv::VideoCapture cap to access the bottom?

      Thanks

        • 1. Re: use opencv to access the bottom camera error
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello tuantuan91,

          Thank you for your interest in the Intel Aero RTF drone.

          We have received your request and we are currently investigating. 
          I will get back to you as soon as possible.

          Regards,
          Eliza

          • 2. Re: use opencv to access the bottom camera error
            tuantuan91

            Hi Eliza

             

            Thanks for your reply.

            In fact my question is could I use opencv 2.4.13 to capture video stream from the bottom camera(/dev/video2) for my code?

            I think this explanation is easier for understanding.

            • 3. Re: use opencv to access the bottom camera error
              tuantuan91

              Hi Eliza

               

              Sorry to disturb you again.

              I just modified my code in this line:

              //cv::VideoCapture cap(0);

              cv::VideoCapture cap("/dev/video2");

               

              I got the Error in Opnecv:

              GStreamer:unable to start pipeline.

              • 4. Re: use opencv to access the bottom camera error
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Hello tuantuan91,

                Thank you for your patience.

                In order for us to be able to understand the issue better, please attach the .cpp file. 
                The bottom camera should be "rtsp://AERO_IP_ON_YOUR_NETWORK:8554/bottom", can you please try that and let me know the outcome? 

                Thank you in advance,
                Eliza

                • 5. Re: use opencv to access the bottom camera error
                  tuantuan91

                  Hi Eliza

                   

                  I think your answer is about using wifi-signal to get video stream on QGC.

                  But for my question I want to know how to use Opencv(C++) to access the bottom camera's video stream on ubuntu.

                  I'm doing some research in visual odometry.

                  These are different problem.

                  • 6. Re: use opencv to access the bottom camera error
                    tuantuan91

                    Hi Eliza

                     

                    Here is the cpp.file I wrote.

                     

                    // This file is part of SVO - Semi-direct Visual Odometry.

                    //

                    // Copyright (C) 2014 Christian Forster <forster at ifi dot uzh dot ch>

                    // (Robotics and Perception Group, University of Zurich, Switzerland).

                    //

                    // SVO is free software: you can redistribute it and/or modify it under the

                    // terms of the GNU General Public License as published by the Free Software

                    // Foundation, either version 3 of the License, or any later version.

                    //

                    // SVO is distributed in the hope that it will be useful, but WITHOUT ANY

                    // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

                    // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

                    //

                    // You should have received a copy of the GNU General Public License

                    // along with this program.  If not, see <http://www.gnu.org/licenses/>.

                     

                     

                    #include <svo/config.h>

                    #include <svo/frame_handler_mono.h>

                    #include <svo/map.h>

                    #include <svo/frame.h>

                    #include <vector>

                    #include <string>

                    #include <svo/math_lib.h>

                    #include <svo/camera_model.h>

                    #include <opencv2/opencv.hpp>

                    #include <sophus/se3.h>

                    #include <iostream>

                     

                     

                    #include <svo/slamviewer.h>

                    #include<thread>

                     

                     

                    class BenchmarkNode

                    {

                        svo::AbstractCamera* cam_;

                        svo::PinholeCamera* cam_pinhole_;

                        svo::FrameHandlerMono* vo_;

                     

                     

                        SLAM_VIEWER::Viewer* viewer_;

                        std::thread * viewer_thread_;

                     

                     

                    public:

                        BenchmarkNode();

                        ~BenchmarkNode();

                        void runFromFolder();

                    };

                     

                     

                    BenchmarkNode::BenchmarkNode()

                    {

                        /*

                        cam_pinhole_ = new svo::PinholeCamera(640,480,502.961104,503.651566, 284.978460, 247.527333,

                                                              -0.378740,0.133422, -0.001505, -0.001445);

                        cam_ = new svo::PinholeCamera(640,480,407.763641, 453.693298, 267.111836,247.958895);

                         */

                        cam_ = new svo::PinholeCamera(640,480,482.62565,480.83271, 323.96419, 261.20336, -0.031563,0.165711,0.001507,-0.00083,-0.18942);

                     

                     

                     

                     

                        vo_ = new svo::FrameHandlerMono(cam_);

                        vo_->start();

                     

                     

                        viewer_ = new SLAM_VIEWER::Viewer(vo_);

                        viewer_thread_ = new std::thread(&SLAM_VIEWER::Viewer::run,viewer_);

                        viewer_thread_->detach();

                     

                     

                    }

                     

                     

                    BenchmarkNode::~BenchmarkNode()

                    {

                        delete vo_;

                        delete cam_;

                        delete cam_pinhole_;

                     

                     

                        delete viewer_;

                        delete viewer_thread_;

                    }

                     

                     

                    //#define TXTREAD

                    void BenchmarkNode::runFromFolder()

                    {

                     

                     

                        cv::VideoCapture cap(1);  // open the default camera

                     

                     

                        if (!cap.isOpened())  // check if we succeeded

                            return ;

                     

                     

                        int img_id = 0;

                        for (;;) {

                     

                     

                            cv::Mat image;

                            cap.read(image);  // get a new frame from camera

                     

                     

                            assert(!image.empty());

                            img_id++;

                     

                     

                            cv::imshow("origin_image", image);

                            if (cv::waitKey(1) >= 0) break;

                            if(img_id < 100) continue;

                     

                     

                            cv::cvtColor(image,image,CV_BGR2GRAY);

                            /*

                            cv::Mat unimg;

                            cam_pinhole_->undistortImage(image,unimg);

                            vo_->addImage(unimg, 0.01*img_id);

                             */

                            vo_->addImage(image, 0.01*img_id);

                     

                     

                            // display tracking quality

                            if(vo_->lastFrame() != NULL)

                            {

                                std::cout << "Frame-Id: " << vo_->lastFrame()->id_ << " \t"

                                          << "#Features: " << vo_->lastNumObservations() << " \n";

                                //<< "Proc. Time: " << vo_->lastProcessingTime()*1000 << "ms \n";

                                std::cout<<"Frame pose: "<< vo_->lastFrame()->T_f_w_ <<std::endl;

                     

                     

                            }

                     

                     

                        }

                     

                     

                        cap.release();

                        return;

                     

                     

                    }

                     

                     

                     

                     

                    int main(int argc, char** argv)

                    {

                     

                     

                     

                     

                        BenchmarkNode benchmark;

                        benchmark.runFromFolder();

                     

                     

                        printf("BenchmarkNode finished.\n");

                        return 0;

                    }

                    • 7. Re: use opencv to access the bottom camera error
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      Hello tuantuan91,

                      The camera from Intel Aero Ready to Fly drone needs to be accessed a certain way. 
                      You can check how to open the camera using V4L2 APIs and then try to use other libraries that will call V4L2 APIs for you. Bellow is the link for a source code that will show you how to to access the camera.
                      https://github.com/intel-aero/sample-apps/blob/master/capturev4l2/capture.cpp

                      Please let me know in case you have any other questions.

                      Best regards!
                      Eliza

                      1 of 1 people found this helpful
                      • 8. Re: use opencv to access the bottom camera error
                        tuantuan91

                        Hi Eliza

                         

                        Thanks for your help.