Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Access IP camera from Qt

Access IP camera from Qt

Scheduled Pinned Locked Moved Solved Mobile and Embedded
ip cameracameraqml
18 Posts 5 Posters 14.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mkrrM Offline
    mkrrM Offline
    mkrr
    wrote on last edited by A Former User
    #1

    I need to access a IP camera from my Qt Application. I'm using the src of the camera image (http://192.168.0.110/image/jpeg.cgi) and updating this image with a Timer on QML.

    Timer {
            interval: 200
            running: true
            repeat: true
            onTriggered:  {
                image1.cache =false;
                image1.source = "http://192.168.0.110/image/jpeg.cgi";
            }
        }
    

    Executing only the code with the Camera, it works fine. The problem happen when I load all the application, the Camera is updated very slow. I'm using a embedded Linux and the resources are limited (512MB RAM, ARM Cortex-A5 500 MHz ). Besides, I need to use the QT4.8 to do this (necessarily).

    Any idea to improve the performance? Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What sizes are the images ? Can you configure your camera to send something more "friendly" e.g. RGB images ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      mkrrM 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        What sizes are the images ? Can you configure your camera to send something more "friendly" e.g. RGB images ?

        mkrrM Offline
        mkrrM Offline
        mkrr
        wrote on last edited by
        #3

        Thanks for your answer @SGaist . Well, By default my camera configurations is: Resolution: 320x240, FPS: 15, Jpeg Quality : Medium. With these configurations, is very slow the update of the image.

        I tryed to configure as: Resolution: 160x120, FPS: 15, Jpeg Quality: Very slow. Its works more fast, but the quality is very bad.

        I think that maybe there are another way to do camera streamming, without get of the image from link (http://192.168.0.110/image/jpeg.cgi) in a interval.. :(

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What type of camera is it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          mkrrM 1 Reply Last reply
          0
          • M Offline
            M Offline
            mvuori
            wrote on last edited by
            #5

            "Very slow" doesn't tell much. But apparently you are asking for a frame every 200 ms, giving 5 fps, which obviously is very slow if you expect normal video display quality...

            mkrrM 1 Reply Last reply
            0
            • SGaistS SGaist

              What type of camera is it ?

              mkrrM Offline
              mkrrM Offline
              mkrr
              wrote on last edited by
              #6

              @SGaist

              I'm using a camera D-LINK DCS-930L. Thanks

              1 Reply Last reply
              0
              • M mvuori

                "Very slow" doesn't tell much. But apparently you are asking for a frame every 200 ms, giving 5 fps, which obviously is very slow if you expect normal video display quality...

                mkrrM Offline
                mkrrM Offline
                mkrr
                wrote on last edited by
                #7

                @mvuori Yes, I think strange too. But, I'm using the same program to do written on serial port. Each written on serial port is with interval around 300ms. The return of the serial port, is writing on QML too.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Are you doing any blocking function call ? e.g. for your serial port ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  mkrrM 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Are you doing any blocking function call ? e.g. for your serial port ?

                    mkrrM Offline
                    mkrrM Offline
                    mkrr
                    wrote on last edited by
                    #9

                    @SGaist No, I'm using a Qthread to execute the serial port

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Can you describe the various parts of your application so we can ensure that they are not influencing each other.

                      By the way, there's no need to set cache each time. Just set the property where you declarer image1. That's one less thing consuming time uselessly.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      mkrrM 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Can you describe the various parts of your application so we can ensure that they are not influencing each other.

                        By the way, there's no need to set cache each time. Just set the property where you declarer image1. That's one less thing consuming time uselessly.

                        mkrrM Offline
                        mkrrM Offline
                        mkrr
                        wrote on last edited by mkrr
                        #11

                        @SGaist It's my main function:

                        int main(int argc, char *argv[])
                        {
                            QApplication app(argc, argv);
                            QDeclarativeView *engine = new QmlApplicationViewer();
                            
                            Gps *gps = new Gps(); // Class to read Gps (serial port 0). Interval: 10000ms
                            
                            SerialPort *serial = new SerialPort(); // Read Serial Port (serial port 1). Interval: 300ms
                            
                           if(serial->getMonitor()) {
                                qDebug() << "Starting Monitor";
                                Monitor *monitor = new Monitor(engine, serial);
                                serial->setMonitor(monitor);
                            }
                            return app.exec();
                        }
                        

                        The class SerialPort start the write on serial port with a forever loop. Its working well, without delays.

                        When the serial read the response, the response is sent to monitor Class and this class is responsable to format the digits and write on screen (QML file). Therefore, each 300 ms my QML file is updated too (with the response of serial port).

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Then where's the camera in that setup ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          mkrrM 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Then where's the camera in that setup ?

                            mkrrM Offline
                            mkrrM Offline
                            mkrr
                            wrote on last edited by
                            #13

                            @SGaist The camera is loaded in a different QML, look:

                            import QtQuick 1.1
                            
                            Rectangle {
                                width: 300
                                height: 400
                            
                                Image {
                                    id: camera1
                                    objectName: "camera1"
                                    x: 39
                                    y: 0
                                    width: 160
                                    height: 120
                                    source: "http://192.168.0.110/image/jpeg.cgi"
                                    cache: false
                            
                                    Timer {
                                        interval: 300
                                        running: true
                                        repeat: true
                                        onTriggered: {
                                            camera1.source = "http://192.168.0.110/image/jpeg.cgi";
                                        }
                                    }
                                }
                            ...
                            }
                            
                            

                            The QML is loaded on Monitor class:

                            Monitor::Monitor(QDeclarativeView *engine, Monitor *m)
                            {
                                engine->setSource(QUrl("qrc:/views/Monitor.qml"));
                            
                                window = qobject_cast< QObject * >( engine->rootObject() );
                            
                                engine->showFullScreen();
                                monitor = m;
                            
                                engine->rootContext()->setContextProperty("mainmonitor",this);
                            }
                            
                            1 Reply Last reply
                            0
                            • K Offline
                              K Offline
                              kolegs
                              wrote on last edited by
                              #14

                              You can also try to load next image when previous one is loaded by checking the status.
                              I use this in my application when loading jpeg from cameras.
                              You just need to set 2 Image objects and show them when Image is ready

                              mkrrM 1 Reply Last reply
                              0
                              • K kolegs

                                You can also try to load next image when previous one is loaded by checking the status.
                                I use this in my application when loading jpeg from cameras.
                                You just need to set 2 Image objects and show them when Image is ready

                                mkrrM Offline
                                mkrrM Offline
                                mkrr
                                wrote on last edited by
                                #15

                                @kolegs how I can do to check the status? Could you show an exemple? Are you using the QML Time to update the frames? Thank you

                                1 Reply Last reply
                                0
                                • K Offline
                                  K Offline
                                  kolegs
                                  wrote on last edited by
                                  #16

                                  You just need to create two Images with same position add property

                                  visible: status == Image.ready
                                  

                                  and on also add sth like this

                                  onStatusChanged:{
                                     if(status == Image.ready){
                                        //here reload the other image
                                        image2.source = "";
                                        image2.source = cameraSource;
                                     }
                                  }
                                  

                                  Add the same thing in image2 but this timer reload image1

                                  onStatusChanged:{
                                     if(status == Image.ready){
                                        //here reload the other image
                                        image1.source = "";
                                        image1.source = cameraSource;
                                     }
                                  }
                                  

                                  Also at creation just set source to cameraSource for one image and for the other leave it empty,.

                                  Hope it helps.

                                  mkrrM C 2 Replies Last reply
                                  1
                                  • K kolegs

                                    You just need to create two Images with same position add property

                                    visible: status == Image.ready
                                    

                                    and on also add sth like this

                                    onStatusChanged:{
                                       if(status == Image.ready){
                                          //here reload the other image
                                          image2.source = "";
                                          image2.source = cameraSource;
                                       }
                                    }
                                    

                                    Add the same thing in image2 but this timer reload image1

                                    onStatusChanged:{
                                       if(status == Image.ready){
                                          //here reload the other image
                                          image1.source = "";
                                          image1.source = cameraSource;
                                       }
                                    }
                                    

                                    Also at creation just set source to cameraSource for one image and for the other leave it empty,.

                                    Hope it helps.

                                    mkrrM Offline
                                    mkrrM Offline
                                    mkrr
                                    wrote on last edited by
                                    #17

                                    @kolegs Thank you so much. I created this code and the performance was very better. I'm reading two IP cameras now with it.

                                    Of course that the delay is existing (each 2 seconds the image is updated). I think that I need to improve my code. I'm using 98% of my CPU, but I need to do many routines :(

                                    Thank you so much again

                                    1 Reply Last reply
                                    0
                                    • K kolegs

                                      You just need to create two Images with same position add property

                                      visible: status == Image.ready
                                      

                                      and on also add sth like this

                                      onStatusChanged:{
                                         if(status == Image.ready){
                                            //here reload the other image
                                            image2.source = "";
                                            image2.source = cameraSource;
                                         }
                                      }
                                      

                                      Add the same thing in image2 but this timer reload image1

                                      onStatusChanged:{
                                         if(status == Image.ready){
                                            //here reload the other image
                                            image1.source = "";
                                            image1.source = cameraSource;
                                         }
                                      }
                                      

                                      Also at creation just set source to cameraSource for one image and for the other leave it empty,.

                                      Hope it helps.

                                      C Offline
                                      C Offline
                                      claudia0078
                                      Banned
                                      wrote on last edited by
                                      #18
                                      This post is deleted!
                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved