Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VideoSourceCapabilities.cpp
1 #include "VideoSourceCapabilities.hh"
2 
3 using namespace BIAS;
4 using namespace std;
5 
8 {
9 
10 }
11 
12 
15 {
16 
17 }
18 
19 
21 {
22  Inputs_.clear();
23  AllResolutions_.clear();
24 }
25 
26 
27 
29 AddMode(unsigned int width, unsigned int height, float fps,
30  ImageBase::EColorModel colormodel, bool interlaced)
31 {
32  if (!HasMode(width,height,fps,colormodel,interlaced)) {
34  e.width = width;
35  e.height = height;
36  e.fps = fps;
37  e.colormodel = colormodel;
38  e.interlaced = interlaced;
39  AllResolutions_.push_back(e);
40  }
41 }
42 
45 {
46  // cout <<"VideoSourceCabilities::AddInput()"<<endl;;
47  Inputs_.push_back(id);
48 }
49 
50 
51 
53 HasMode(unsigned int width, unsigned int height, float fps,
54  ImageBase::EColorModel colormodel,bool interlaced)
55 {
56 
57  for (unsigned int i=0;i<AllResolutions_.size();i++ ) {
58  ResolutionEntry &e = AllResolutions_[i];
59  if (e.width == width && e.height == height &&e.fps==fps
60  && e.colormodel == colormodel)
61  return true;
62  }
63  return false;
64 }
65 
66 
69 {
70  cout <<"VideoSourceCapabilities for device: "<<endl;
71  cout <<" "<<Name_<<endl;
72  for (unsigned int i=0;i<Inputs_.size();i++ ) {
73  InputDescriptor &id = Inputs_[i];
74  cout <<"Input "<<id.number<<endl;
75  cout <<" Name: "<<id.name<<endl;
76  }
77 
78  for (unsigned int i=0;i<AllResolutions_.size();i++ ) {
79  ResolutionEntry &e = AllResolutions_[i];
80  cout <<"Mode "<<i<<" "<<e.width<<"x"<<e.height<<" fps: "<<e.fps
81  <<" colormodel: "<<e.colormodel<<endl;
82  }
83 }
84 
86 GetBestForEachResolution(std::vector<ResolutionEntry> &res)
87 {
88  res.clear();
89  for (unsigned int i=0;i<AllResolutions_.size();i++ ) {
90  ResolutionEntry &e = AllResolutions_[i];
91  bool found = false;
92  for (unsigned int j=0;j<res.size();j++ ) {
93  if (e.width == res[j].width && e.height== res[j].height) {
94  // if resolution is equal and fps is better, update entry
95  if (e.fps >res[j].fps) res[j] = e;
96  found = true;
97  break;
98  }
99  }
100  if (!found) res.push_back(e);
101  }
102 }
EColorModel
These are the most often used color models.
Definition: ImageBase.hh:127
void AddMode(unsigned int width, unsigned int height, float fps, ImageBase::EColorModel colormodel, bool interlaced=false)
bool HasMode(unsigned int width, unsigned int height, float fps, ImageBase::EColorModel colormodel, bool interlaced)
void GetBestForEachResolution(std::vector< ResolutionEntry > &res)