Results 1 to 5 of 5

Thread: class qcamera some help or more examples?

  1. #1
    Join Date
    Sep 2016
    Posts
    78
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default class qcamera some help or more examples?

    Hi i am trying to record my camera with qcamera but i dont have many experience.
    I declare in headers this:
    Qt Code:
    1. #include <QPixmap>
    2. #include <QDir>
    3. #ifdef Q_WS_WIN
    4. #include <windows.h>
    5. #include <vfw.h>
    6. #endif
    7. class QCamera;
    8. class QCameraViewfinder;
    9. class QCameraImageCapture;
    10. class QMenu;
    11. class QAction;
    12. QAction *mEncenderAction;
    13. QAction *mApagarAction;
    14. QAction *mCapturarAction;
    15. QPixmap capturar();
    16. void encender();
    17. void apagar();
    To copy to clipboard, switch view to plain text mode 
    cpp file:
    Qt Code:
    1. #include "../headers/webcamwin.h"
    2. #include <QFile>
    3. #include <QCamera>
    4. #include <QCameraViewfinder>
    5. #include <QCameraImageCapture>
    6. #include <QVBoxLayout>
    7. #include <QMenu>
    8. #include <QAction>
    9. #include <QFileDialog>
    10. void encender()
    11. {
    12. connect(mApagarAction,&QAction::triggered,&{
    13. mCamera->start();
    14. });
    15. }
    16. void apagar()
    17. {
    18. mCamera->stop();
    19. }
    20. QPixmap capturar()
    21. {
    22. connect(mCapturarAction,&QAction::triggered,[&](){
    23. auto filename = QFileDialog::getSaveFileName(this,"Capturar","/",
    24. "Imagen(*.jpg;*.jpeg)");
    25. if(filename.isEmpty()){
    26. return;
    27. }
    28. mCameraImageCapture->setCaptureDestination(
    29. QCameraImageCapture::CaptureToFile);
    30. QImageEncoderSettings imageEncoderSettings;
    31. imageEncoderSettings.setCodec("image/jpeg");
    32. imageEncoderSettings.setResolution(1600,1200);
    33. mCameraImageCapture->setEncodingSettings(imageEncoderSettings);
    34. mCamera->setCaptureMode(QCamera::CaptureStillImage);
    35. mCamera->start();
    36. mCamera->searchAndLock();
    37. mCameraImageCapture->capture(filename);
    38. mCamera->unlock();
    39. });
    40. }
    To copy to clipboard, switch view to plain text mode 
    Obviously doesnt work. I only want that when i call one determined function, the camera do (up,off, or record)
    Last edited by anda_skoa; 25th September 2016 at 09:50. Reason: changed [quote] to [code]

  2. #2
    Join Date
    Sep 2016
    Posts
    78
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default Re: class qcamera some help or more examples?

    I tried with this:

    #include "../headers/webcamwin.h"
    #include <QFile>
    HWND hwndVideo; // video capture window
    void encender()
    {
    ::hwndVideo = capCreateCaptureWindowA("captura",WS_POPUP ,1,1 ,240 ,320,NULL,0);
    capDriverConnect(::hwndVideo,0);
    capPreviewRate(::hwndVideo,100);
    capPreviewScale(::hwndVideo,false);
    }

    void apagar()
    {
    capDriverDisconnect(::hwndVideo);
    DestroyWindow(::hwndVideo);
    ::hwndVideo = NULL;
    }

    QPixmap capturar()
    {
    capGrabFrame(::hwndVideo);
    QPixmap imagen;
    QFile crear;
    crear.setFileName("data");
    crear.open(QFile::WriteOnly);
    crear.close();
    capFileSaveDIB(::hwndVideo,L"data");
    imagen.load("data");
    return imagen;
    }
    But i dont know how to include Windows api for using my camera. And people recommend me qcamera instead of Windows api.

  3. #3
    Join Date
    Sep 2016
    Posts
    78
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default Re: class qcamera some help or more examples?

    solved solved thx

  4. #4
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: class qcamera some help or more examples?

    Why don't you post what you did to solve this so that others might benefit?
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  5. #5
    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: class qcamera some help or more examples?

    Why don't you post what you did to solve this so that others might benefit?
    Too busy posting a half dozen other questions he will also eventually answer himself if he took time out to think instead of posting. Seems particularly resistant to learning how to use [CODE] blocks instead of [QUOTE], despite having been asked numerous times.
    <=== 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.

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

    jefftee (26th September 2016)

Similar Threads

  1. How to get QCamera to work?
    By feraudyh in forum Qt Programming
    Replies: 9
    Last Post: 24th June 2020, 22:05
  2. Not able to start camera using QCamera class
    By pratik.manvar in forum Qt Programming
    Replies: 0
    Last Post: 27th June 2016, 10:26
  3. How could I get the image buffer of QCamera?
    By stereoMatching in forum Qt Programming
    Replies: 7
    Last Post: 22nd April 2015, 20:56
  4. Replies: 1
    Last Post: 7th March 2013, 00:30
  5. Set zoomTo for QCamera?
    By tamnv110 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 29th August 2011, 13:54

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.