Results 1 to 8 of 8

Thread: To Display Video Frames from webcam on QML

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: To Display Video Frames from webcam on QML

    Seems that you have added your image provider with the name "color" but are trying to access "colors".

  2. The following user says thank you to ChrisW67 for this useful post:


  3. #2
    Join Date
    May 2013
    Posts
    11
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: To Display Video Frames from webcam on QML

    ChrisW67 I have changed the "color" to "colors". Even though I am getting the same error. I am not sure with the syntax. Is it correct to mention the image name in qml or I should load the image with qpixmap.

  4. The following user says thank you to bts-007 for this useful post:


  5. #3
    Join Date
    May 2013
    Posts
    11
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: To Display Video Frames from webcam on QML

    with no other option I tried the example program from nokia developer site here is the link

    http://harmattan-dev.nokia.com/docs/...eprovider.html

    when I tried the above example I got an error message "QML Image:Failed to get image from provider: image://colors/yellow"

    Here is the code with few changes from example

    main.cpp

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "qmlapplicationviewer.h"
    3. #include <QDeclarativeEngine>
    4. #include <QDeclarativeImageProvider>
    5.  
    6.  
    7. class ColorImageProvider : public QDeclarativeImageProvider
    8. {
    9. public:
    10. ColorImageProvider()
    11. : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap)
    12. {
    13. }
    14.  
    15. QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
    16. {
    17. int width = 100;
    18. int height = 50;
    19.  
    20. if (size)
    21. *size = QSize(width, height);
    22. QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width,
    23. requestedSize.height() > 0 ? requestedSize.height() : height);
    24. pixmap.fill(QColor(id).rgba());
    25.  
    26. return pixmap;
    27. }
    28. };
    29.  
    30. int main(int argc, char *argv[])
    31. {
    32. QScopedPointer<QApplication> app(createApplication(argc, argv));
    33.  
    34. QmlApplicationViewer viewer;
    35. viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    36. viewer.setMainQmlFile(QLatin1String("qml/yellow_red_imageprovider/main.qml"));
    37. viewer.showExpanded();
    38.  
    39. QDeclarativeEngine engine;
    40. engine.addImageProvider(QLatin1String("colors"), new ColorImageProvider);
    41.  
    42.  
    43. return app->exec();
    44. }
    To copy to clipboard, switch view to plain text mode 

    main.qml
    Qt Code:
    1. import QtQuick 1.1
    2.  
    3. Column {
    4. Image { source: "image://colors/red" }
    5. Image { source: "image://colors/yellow" }
    6. }
    To copy to clipboard, switch view to plain text mode 

    I don't know how to solve this problem

  6. #4
    Join Date
    May 2013
    Posts
    11
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: To Display Video Frames from webcam on QML

    I made some changes in the main file. getting the same error . what is the solution

    main.cpp
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QScopedPointer<QApplication> app(createApplication(argc, argv));
    4.  
    5.  
    6. QmlApplicationViewer viewer;
    7. viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    8. viewer.setMainQmlFile(QLatin1String("qml/yellow_red_imageprovider/main.qml"));
    9. viewer.showExpanded();
    10. //QDeclarativeEngine engine;
    11. //engine.addImageProvider(QLatin1String("colors"), new ColorImageProvider);
    12. viewer.engine()->addImageProvider("colors", new ColorImageProvider);
    13.  
    14. return app->exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to bts-007 for this useful post:


  8. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: To Display Video Frames from webcam on QML

    May be because you are returning QPixmap instead of QImage ! ??

    Sorry,,, Dint see the class QDeclarativeImageProvider properly You can use requestPixmap() too

Similar Threads

  1. Need access to individual video frames
    By themagician in forum Newbie
    Replies: 2
    Last Post: 26th November 2012, 13:40
  2. Webcam Video Capture
    By bajoelkid12 in forum Qt Programming
    Replies: 28
    Last Post: 25th December 2011, 03:28
  3. How to drop some frames while playing video?
    By cic in forum Qt Programming
    Replies: 0
    Last Post: 11th November 2011, 14:49
  4. Replies: 8
    Last Post: 18th March 2011, 11:27
  5. Help displaying frames from a webcam to the screen
    By stealth86 in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2007, 18:48

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.