-
Notifications
You must be signed in to change notification settings - Fork 16
/
livevideo.cpp
55 lines (46 loc) · 1.3 KB
/
livevideo.cpp
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
#include "livevideo.h"
#include <stdio.h>
#include <iostream>
using namespace std;
liveVideo::~liveVideo()
{
}
void liveVideo::startCapture()
{
liveCapture = cvCaptureFromCAM(0);
for(;;)
{
tmpImage = cvQueryFrame(liveCapture);
if( tmpImage && (playStatus) )
{
cvWaitKey(30);
}
else
{
break;
}
}
}
void liveVideo::stopCapture()
{
cvReleaseCapture( &liveCapture );
}
void liveVideo::initliveVideo()
{
}
void liveVideo::displayVideo(IplImage *imagetoDisplay,QGraphicsView *graphicsObject)
{
cvCvtColor(imagetoDisplay,imagetoDisplay,CV_BGR2RGB);
QImage image = QImage((uchar *)imagetoDisplay->imageData, imagetoDisplay->width, imagetoDisplay->height, QImage::Format_RGB888);
QGraphicsScene* scene = new QGraphicsScene(graphicsObject);
QPixmap tempimage = QPixmap::fromImage(image);
QPixmap *backgroundPixmap = &tempimage;
QPixmap sized = backgroundPixmap->scaled(QSize(graphicsObject->width(),graphicsObject->height()),Qt::IgnoreAspectRatio);
QImage sizedImage = QImage(sized.toImage());
scene->addPixmap(QPixmap::fromImage(sizedImage));
graphicsObject->setScene(scene);
}
void liveVideo::togglePlayStatus()
{
playStatus = (!playStatus);
}