Results 1 to 10 of 10

Thread: How to get QCamera to work?

  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to get QCamera to work?

    I want to use QCamera, but the page on QCamera does not say how I must change my project file to use it.
    I've got QT += multimedia multimediawidgets
    but this appears to be insufficient.
    It seems to me that for every class the doc hould mention this kind of detail.


    Added after 18 minutes:


    It seems now that i just had to wait several minutes before QtCreator woke up to the fact that I had added
    QT += multimedia multimediawidgets
    to the project file
    and now "magically"
    #include <QCameraViewfinder>
    #include <QCamera>
    are no longer underlined in green.

    problem solved, but my remark about the doc still holds.
    Last edited by feraudyh; 31st January 2014 at 21:25.

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

    Default Re: How to get QCamera to work?

    Get into the habit of running qmake after you modify a PRO file.

    The modification required to the PRO file is documented at the module level.
    Qt Multimedia

  3. #3
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to get QCamera to work?

    Hi,
    I've used QCamera on Windows, now I'd like to port my stuff to Linux.
    I downloaded Qt 5.2.1 on XUbuntu, and I've got a message saying QCamera cannot be found (when I try to #include <QCamera>)
    Does anyone know if QCamera is planned, or do I just need to download some extensions?

  4. #4
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Is QCamera supported on Linux?

    It seems that the QtCreator 3.0.1 + Qt 5.2.1 does not support QCamera on Xubuntu.
    Any workarounds? Any plans for it to be released in the near future?
    Furthermore the MultimediaWidgets module is rejected by qmake.

  5. #5
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Is QCamera supported on Linux?

    QCamera worked for me on Linux Mint (latest release) with gstreamer backend - I can't remember exactly, but I think I had to install the "bad" plugins set (gst-plugins-bad) and build the QCamera gstreamer plugin from source ("qtmultimedia\src\plugins\gstreamer\camerabin" ). I didn't care about the audio, so I can't really help you with that.
    Anyway, every camera I tested supported only one basic capture mode (typically 800x600@20 fps), without the possibility to change it, even if hardware supports much bigger resolutions / framerates.

  6. #6
    Join Date
    Mar 2015
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get QCamera to work?

    Hi,

    I am having problem in recording video using QMediaRecorder and QCamera classes.
    My application crashes with segmentation fault when trying to start camera ("camera->start" in code).

    Below is code, i have written. Please guide me out here, if have i am missing something. Thanks in advance.
    Qt Code:
    1. /**********************************************************************/
    2. QMediaRecorder *recorder;
    3. QCamera *camera;
    4. QCameraViewfinder *viewfinder;
    5.  
    6. QCameraInfo cameraInfo(camera);
    7. QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
    8. foreach (cameraInfo, cameras)
    9. qDebug() << cameraInfo.deviceName();
    10.  
    11. camera = new QCamera(cameraInfo);
    12.  
    13. viewfinder = new QCameraViewfinder();
    14. camera->setViewfinder(viewfinder);
    15. setCentralWidget(viewfinder);
    16. viewfinder->show();
    17.  
    18. if(true == isCaptureModeSupported(QCamera::CaptureVideo)
    19. {
    20. camera->setCaptureMode(QCamera::CaptureVideo);
    21. }
    22.  
    23. recorder = new QMediaRecorder(camera);
    24. camera->start();
    25.  
    26. recorder->setOutputLocation(QUrl::fromLocalFile("record.mp4"));
    27. recorder->record();
    28.  
    29. /**********************************************************************/
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 23rd June 2016 at 16:57. Reason: missing [code] tags

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,102
    Thanks
    289
    Thanked 844 Times in 831 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to get QCamera to work?

    Where is this code? In a MainWindow constructor? In the constructor, the MainWindow (and all of its children) are not yet visible and do not have valid sizes. This could be part of the problem - that you are telling the camera to start displaying on a viewfinder window that has not been fully initialized. You are also starting the camera before you have told the recorder where to write its output. Calling "viewfinder->show()" in the constructor is a waste of time. It will be shown when the MainWindow is shown, and that does not happen until the showEvent().

    I would suggest that you implement a showEvent() handler for the MainWindow and move the camera->start() call there. All of the other setup can probably remain where it is. You will need to make the camera instance a member variable of the MainWindow class if it is not already.

    And use CODE tags when posting source code.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  8. The following user says thank you to d_stranz for this useful post:

    pratik.manvar (24th June 2016)

  9. #8
    Join Date
    Mar 2015
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get QCamera to work?

    Hello d_stranz,

    Thanks for your reply.

    The code is not in constructor, there is a push-button to start recording.

    Here with i have attached files of my code. Thanks for the knowledge for pasting source code.
    Attached Files Attached Files

  10. #9
    Join Date
    Jun 2020
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Question Re: How to get QCamera to work?

    can you please add the ui.mainwindow file

  11. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,102
    Thanks
    289
    Thanked 844 Times in 831 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to get QCamera to work?

    You don't really need the specific file for this project. All the poster did was to make the QCameraViewFinder the central widget for a generic MainWindow. Just create a new project, and copy the mainwindow.ui fle from that.

    The last posts from this poster were these, in 2016, and it is very unlikely he is still following this forum.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. How could I get the image buffer of QCamera?
    By stereoMatching in forum Qt Programming
    Replies: 7
    Last Post: 22nd April 2015, 20:56
  2. QCamera images flipped on Windows platform
    By jas67 in forum Qt Programming
    Replies: 4
    Last Post: 22nd March 2013, 12:21
  3. Accessing Symbian Camera trough QCamera
    By daleotar in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 25th September 2011, 17:18
  4. Set zoomTo for QCamera?
    By tamnv110 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 29th August 2011, 13:54
  5. How can I decrease the frame rate of the QCamera?
    By mismael85 in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 9th July 2011, 00:13

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.