-
Notifications
You must be signed in to change notification settings - Fork 1
/
VideoSource_Linux_V4L.cc
36 lines (32 loc) · 1.1 KB
/
VideoSource_Linux_V4L.cc
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
// Copyright 2008 Isis Innovation Limited
#include "VideoSource.h"
#include <cvd/Linux/v4lbuffer.h>
#include <cvd/colourspace_convert.h>
#include <cvd/colourspaces.h>
#include <gvars3/instances.h>
using namespace CVD;
using namespace std;
using namespace GVars3;
VideoSource::VideoSource()
{
cout << " VideoSource_Linux: Opening video source..." << endl;
string QuickCamFile = GV3::get<string>("VideoSource.V4LDevice", "/dev/video0");
ImageRef irSize = GV3::get<ImageRef>("VideoSource.Resolution", ImageRef(640,480));
int nFrameRate = GV3::get<int>("VideoSource.Framerate", 30);
V4LBuffer<yuv422>* pvb = new V4LBuffer<yuv422>(QuickCamFile, irSize, -1, false, nFrameRate);
mirSize = pvb->size();
mptr = pvb;
cout << " ... got video source." << endl;
};
ImageRef VideoSource::Size()
{
return mirSize;
};
void VideoSource::GetAndFillFrameBWandRGB(Image<byte> &imBW, Image<Rgb<byte> > &imRGB)
{
V4LBuffer<yuv422>* pvb = (V4LBuffer<yuv422>*) mptr;
VideoFrame<yuv422> *pVidFrame = pvb->get_frame();
convert_image(*pVidFrame, imBW);
convert_image(*pVidFrame, imRGB);
pvb->put_frame(pVidFrame);
}