Help with my camera qt



  • Hi i am trying to record my camera i used this code:

    #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 get these errors:
    C2065: 'WS_POPUP' : undeclared identifier
    and more errors like identifier not found.

    My question is: I need to include some class or some library. Thanks in advance.


  • Moderators

    Why do you use the Windows API instead of QCamera?



  • This post is deleted!


  • This post is deleted!


  • Hi i am trying to record my camera with qcamera but i dont have many experience.

    I declare in headers this:

    #include <QPixmap>
    #include <QDir>
    #ifdef Q_WS_WIN
    #include <windows.h>
    #include <vfw.h>
    #endif

    class QCamera;
    class QCameraViewfinder;
    class QCameraImageCapture;
    class QVBoxLayout;
    class QMenu;
    class QAction;

    QAction *mEncenderAction;
    QAction *mApagarAction;
    QAction *mCapturarAction;

    QPixmap capturar();
    void encender();
    void apagar();
    

    cpp file:
    #include "../headers/webcamwin.h"
    #include <QFile>
    #include <QCamera>
    #include <QCameraViewfinder>
    #include <QCameraImageCapture>
    #include <QVBoxLayout>
    #include <QMenu>
    #include <QAction>
    #include <QFileDialog>

    void encender()
    {
    connect(mApagarAction,&QAction::triggered,&{

        mCamera->start();
    });
    

    }

    void apagar()
    {

    mCamera->stop();
    

    }

    QPixmap capturar()
    {

    connect(mCapturarAction,&QAction::triggered,[&](){
        auto filename = QFileDialog::getSaveFileName(this,"Capturar","/",
                                     "Imagen(*.jpg;*.jpeg)");
        if(filename.isEmpty()){
            return;
        }
        mCameraImageCapture->setCaptureDestination(
                              QCameraImageCapture::CaptureToFile);
        QImageEncoderSettings imageEncoderSettings;
        imageEncoderSettings.setCodec("image/jpeg");
        imageEncoderSettings.setResolution(1600,1200);
        mCameraImageCapture->setEncodingSettings(imageEncoderSettings);
        mCamera->setCaptureMode(QCamera::CaptureStillImage);
        mCamera->start();
        mCamera->searchAndLock();
        mCameraImageCapture->capture(filename);
        mCamera->unlock();
    });
    

    }

    Obviously doesnt work. I only want that when i call one determined function, the camera do (up,off, or record). Sorry for all.



  • @RIVOPICO
    I spend a lot of time with the QCamera for my project until I found that that the camera api is nearly not supported for windows.
    Video works never !
    Camera takes always photos with the lowest resolution. No change to change it with Qt.
    No flash or an other feature of the camera is suppoedt.

    So forget the QCamera for windows, I use the integrated windows camera software now,
    but I am very interested how to use the windows api to access the camera in Qt.



  • @Andy314 with qcamera you could take pictures, turn on camera and many things. I dont know why you say this. I was trying with win api because i always do with this way and before works old versions. Now you could use the qcamera and works but i only want to combinate with functions and i am little newbie for this i take help. If you need help i could help you. If you want check in YouTube you will get a easy tutorial:
    https://www.youtube.com/watch?v=9oQZPqi47Y8



  • this is solved you can include the library and works


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.