calibrateVideo.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "Component/ModelManager.H"
00039 #include "Devices/RangeFinder.H"
00040 #include "Component/OptionManager.H"
00041 #include "Devices/Serial.H"
00042 #include "Devices/FrameGrabberConfigurator.H"
00043 #include "Devices/DeviceOpts.H"
00044 #include "Image/DrawOps.H"
00045 #include "Image/Image.H"
00046 #include "Image/ShapeOps.H"
00047 #include "Image/CutPaste.H"
00048 #include "Image/ImageCache.H"
00049 #include "Image/Pixels.H"
00050 #include "Image/MathOps.H"
00051 #include "Image/IO.H"
00052 #include "Image/Layout.H"
00053 #include "GUI/SDLdisplay.H"
00054 #include "GUI/GUIOpts.H"
00055 #include "Raster/Raster.H"
00056 #include "Media/FrameSeries.H"
00057 #include "Transport/FrameIstream.H"
00058 #include "Transport/FrameInfo.H"
00059 #include "Util/Timer.H"
00060 #include "Util/log.H"
00061 #include "Util/sformat.H"
00062 #include "Video/RgbConversion.H"
00063 #include "Raster/DeBayer.H"
00064 #include "Raster/PlaintextWriter.H"
00065 #include <algorithm>
00066 #include <iterator>
00067 #include <queue>
00068 #include <fstream>
00069 #include <iostream>
00070
00071
00072 using namespace std;
00073 Timer tim;
00074
00075 static int submain(const int argc, char** argv)
00076 {
00077
00078 Image<byte> ima(640,480,ZEROS);
00079
00080 uint64 t;
00081
00082
00083 ModelManager manager("getting calibration image from recording camera");
00084
00085 nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(manager));
00086 manager.addSubComponent(ofs);
00087
00088 nub::soft_ref<FrameGrabberConfigurator>
00089 gbc(new FrameGrabberConfigurator(manager));
00090 manager.addSubComponent(gbc);
00091
00092 manager.setOptionValString(&OPT_FrameGrabberType, "XC");
00093 manager.setOptionValString(&OPT_FrameGrabberDims, "640x478");
00094
00095
00096 if (manager.parseCommandLine(argc, argv, "",0,0) == false)
00097 return(1);
00098
00099
00100 nub::soft_ref<FrameIstream> gb = gbc->getFrameGrabber();
00101
00102 if (gb.isInvalid())
00103 LFATAL("You need to have XC camera and XClibrary");
00104
00105
00106 manager.start();
00107
00108
00109 gb->startStream();
00110
00111 while(1)
00112 {
00113
00114 ima = gb->readGray();
00115 Image<PixRGB<byte> > imgByte = ima;
00116 drawCircle(imgByte, Point2D<int>(320,240), 5,PixRGB<byte>(255,0,0));
00117 ofs->writeRGB(imgByte,"Output",FrameInfo("output",SRC_POS));
00118
00119 LINFO("grab on");
00120 t = tim.get();
00121 if(t > 10000)
00122 {
00123 manager.stop();
00124 exit(1);
00125 }
00126 }
00127
00128 manager.stop();
00129 }
00130
00131
00132
00133 extern "C" int main(const int argc, char** argv)
00134 {
00135 try
00136 {
00137 return submain(argc, argv);
00138 }
00139 catch (...)
00140 {
00141 REPORT_CURRENT_EXCEPTION;
00142 }
00143
00144 return 1;
00145 }
00146
00147
00148
00149
00150
00151
00152
00153