-
Notifications
You must be signed in to change notification settings - Fork 0
/
webcam.h
executable file
·90 lines (77 loc) · 1.93 KB
/
webcam.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* webcam.h -- Kapture
*
* Copyright (C) 2006-2007
* Detlev Casanova ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*/
#ifndef _WEBCAM_H
#define _WEBCAM_H
#include <QObject>
#include <QImage>
#include <QSocketNotifier>
#include "imageconvert.h"
#include "hcimage.h"
#include <linux/videodev2.h>
class Webcam : public QObject
{
Q_OBJECT
public:
Webcam();
~Webcam();
void close();
int open();
int open(const char*);
int open(const QString&);
QList<int> getFormatList(QList<QString> &description) const;
QList<QSize> getSizesList() const;
int setFormat(unsigned int width, unsigned int height, int pixelformat=V4L2_PIX_FMT_MJPEG);
int streamOff();
int stopStreaming();
int getFrame(QImage &image);
int getFrame(ColorImage &image);
int getFrameBW(GrayScaleImage &image);
int currentWidth() const;
int currentHeight() const;
int currentPixelFormat() const;
int changeCtrl(int ctrl, int value = 0);
int defaultCtrlVal(unsigned int control, int &defaultValue);
bool isStreaming() const {return streaming;}
bool isOpened() const {return opened;}
bool panTiltSupported();
QString name() const {return m_name;}
enum Control {Saturation = 0,
PowerLineFreq,
Brightness,
Contrast,
Sharpness,
PanTiltReset};
signals:
void imageReady();
public slots:
int startStreaming();
void turnRight();
void turnLeft();
void turnUp();
void turnDown();
private:
int dev;
v4l2_format fmt;
v4l2_buffer buf;
v4l2_requestbuffers rb;
bool allocated;
uchar *mem[2];
size_t bufLength;
QSocketNotifier *imageNotifier;
QImage *image;
bool streaming;
bool opened;
bool mmaped;
QString m_name;
};
#endif