Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VideoSource_Stereo.cpp
1 #ifdef WIN32
2 # pragma warning (disable: 4251) // STL MAP DLL warning noise (JW)
3 #endif
4 
5 #include "VideoSource_Stereo.hh"
6 
7 #include <Image/Camera.hh>
8 #include <string>
9 
10 using namespace BIAS;
11 using namespace std;
12 
15  : VideoSource(), Left_(left), Right_(right)
16 {}
17 
20 {
21  if (Left_){
22  delete Left_;
23  Left_ = NULL;
24  }
25  if (Right_){
26  delete Right_;
27  Right_ = NULL;
28  }
29 }
30 
32 OpenDevice(const char *name)
33 {
34  string mname = name;
35  string::size_type pos = mname.find(':', 0);
36  if (pos == string::npos){
37  BIASERR("invalid name \""<<name<<"\"");
38  return -1;
39  }
40 
41  string lname = mname.substr(0, pos);
42  string rname = mname.substr(pos+1, mname.size()-pos-1);
43  cout << "lname = \""<<lname<<"\"\trname = \""<<rname<<"\"\n";
44  int resl = Left_->OpenDevice(lname.c_str());
45  int resr = Right_->OpenDevice(rname.c_str());
46  return (resl==0 && resr==0)?0:-1;
47 }
48 
49 
52 {
53  BIASERR("use OpenDevice(char *)");
54  BIASABORT;
55  return -1;
56 }
57 
60 {
61  int resl = Left_->PreGrab();
62  int resr = Right_->PreGrab();
63  return (resl==0 && resr==0)?0:-1;
64 }
65 
68 {
69  int resl = Left_->GrabSingle(LeftIm_);
70  int resr = Right_->GrabSingle(RightIm_);
71  image = LeftIm_;
72  return (resl==0 && resr==0)?0:-1;
73 }
74 
77 {
78  int resl = Left_->PostGrab();
79  int resr = Right_->PostGrab();
80  return (resl==0 && resr==0)?0:-1;
81 }
82 
84 SetSize(int w, int h, int bytesperpixel)
85 {
86  Left_->SetSize(w, h, bytesperpixel);
87  Right_->SetSize(w, h, bytesperpixel);
88 }
89 
92 {
93  int resl = Left_->CloseDevice();
94  int resr = Right_->CloseDevice();
95  return (resl==0 && resr==0)?0:-1;
96 }
97 
98 
101 {
102  Left_->InitImage(LeftIm_);
103  Right_->InitImage(RightIm_);
104  return Left_->InitImage(img);
105 }
106 
109 {
110  BIASABORT;
111 }
112 
115 {
116  BIASABORT;
117 }
118 
119 
121 operator=(const VideoSource_Stereo & /*source*/)
122 {
123  BIASABORT;
124  return *this;
125 }
126 
virtual int OpenDevice()
selects the first available device to open (e.g.
Defines a common interface to different devices.
VideoSource_Stereo & operator=(const VideoSource_Stereo &source)
prohibit default function (move to &#39;public&#39; if needed)
virtual int InitImage(ImageBase &img)
bundles two video sources for stereo
virtual int PostGrab()
Stop anything started in PreGrab()
virtual int GrabSingle(Camera< unsigned char > &image)
Returns the left image and captures the right image from the camera.
VideoSource_Stereo()
prohibit default function (move to &#39;public&#39; if needed)
virtual void SetSize(int w, int h, int bytesperpixel)
Set image size and number of bytes per pixel (e.g.
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
virtual int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)