PDA

View Full Version : class qcamera some help or more examples?



davinciomare
25th September 2016, 02:15
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)

davinciomare
25th September 2016, 20:11
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.

davinciomare
26th September 2016, 01:35
solved solved thx

jefftee
26th September 2016, 01:37
Why don't you post what you did to solve this so that others might benefit?

d_stranz
26th September 2016, 17:14
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.