Results 1 to 2 of 2

Thread: Ip camera mjpg to QT Embedded app

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Ip camera mjpg to QT Embedded app

    Hello,

    I'm trying to create a QT program to display the mjpg frames of my ip camera. For this i used QHttp without succes. On the internet i found out that it was also possible with QNetworkAccessManager. Now i've managed to show single images by using QNetworkReply and put it in a QPixmap. I'm sure it als must be possible for mjpg images but i can't figure out how.

    Can anyone give me some advise. I can't use Opencv because finaly the application has to be written in QT embedded. If i'm right, i have to use the virtual framebuffer to show the mjpg images of the camera.

    Below you can see my code.

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. m_netwManager = new QNetworkAccessManager(this);
    7. connect(m_netwManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slot_netwManagerFinished(QNetworkReply*)));
    8. connect(m_netwManager,SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),this,SLOT(slot_netwManagerFinished(QNetworkReply*,QAuthenticator*)));
    9. }
    10.  
    11. void MainWindow::on_action_Download_triggered()
    12. {
    13. QUrl url(ui->txtImageAddress->text());
    14. QNetworkRequest request(url);
    15. m_netwManager->get(request);
    16. }
    17.  
    18. void MainWindow::slot_netwManagerFinished(QNetworkReply*,QAuthenticator* auth)
    19. {
    20. auth->setUser("admin");
    21. auth->setPassword("admin");
    22. }
    23.  
    24. void MainWindow::slot_netwManagerFinished(QNetworkReply *reply)
    25. {
    26.  
    27. if (reply->error() != QNetworkReply::NoError) {
    28. reply->deleteLater();
    29. return;
    30. }
    31.  
    32. QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
    33.  
    34. if (contentType == "image/jpeg")
    35. {
    36.  
    37. QVariant redir = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    38. if (redir.isValid()) {
    39. QUrl url = redir.toUrl();
    40. if (url.isRelative()) {
    41. url.setScheme(reply->url().scheme());
    42. url.setEncodedHost(reply->url().encodedHost());
    43. }
    44. QNetworkRequest req(url);
    45. m_netwManager->get(req);
    46. reply->deleteLater();
    47. return;
    48. }
    49.  
    50. QByteArray jpegData = reply->readAll();
    51.  
    52. QPixmap pixmap;
    53. pixmap.loadFromData(jpegData);
    54. ui->lblImage->setPixmap(pixmap);
    55.  
    56. reply->deleteLater();
    57.  
    58. }
    59. else
    60. {
    61. //VIDEO MJPG DATA
    62.  
    63.  
    64. }
    65. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2016
    Posts
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Android

    Default Re: Ip camera mjpg to QT Embedded app

    Use this widget:
    https://github.com/jgehring/qmpwidge.../qmpwidget.cpp

    install mplayer and use the rtsp option

Similar Threads

  1. Access and view IP camera from Qt
    By Qt Coder in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2014, 09:35
  2. Connect camera in Qt?
    By nthung in forum Qt Programming
    Replies: 12
    Last Post: 25th May 2010, 11:19
  3. IP camera
    By vinod sharma in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2010, 13:41
  4. Camera Detection
    By tiho_bg in forum Qt Programming
    Replies: 0
    Last Post: 18th November 2009, 20:09
  5. Firewire Camera driver
    By hgedek in forum General Discussion
    Replies: 0
    Last Post: 1st October 2007, 20:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.