Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Help with my camera qt

Help with my camera qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Why do you use the Windows API instead of QCamera?

      RIVOPICOR 1 Reply Last reply
      0
      • RIVOPICOR Offline
        RIVOPICOR Offline
        RIVOPICO
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • ? A Former User

          Why do you use the Windows API instead of QCamera?

          RIVOPICOR Offline
          RIVOPICOR Offline
          RIVOPICO
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • RIVOPICOR Offline
            RIVOPICOR Offline
            RIVOPICO
            wrote on last edited by RIVOPICO
            #5

            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.

            Andy314A 1 Reply Last reply
            0
            • RIVOPICOR RIVOPICO

              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.

              Andy314A Offline
              Andy314A Offline
              Andy314
              wrote on last edited by Andy314
              #6

              @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.

              RIVOPICOR 1 Reply Last reply
              0
              • Andy314A Andy314

                @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.

                RIVOPICOR Offline
                RIVOPICOR Offline
                RIVOPICO
                wrote on last edited by
                #7

                @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

                1 Reply Last reply
                0
                • RIVOPICOR Offline
                  RIVOPICOR Offline
                  RIVOPICO
                  wrote on last edited by
                  #8

                  this is solved you can include the library and works

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved