27 #include <Base/Common/W32Compat.hh>
33 #include "VideoSource_Disk.hh"
34 #include <Base/Image/ImageIO.hh>
35 #include <Base/Image/ImageAttributes.hh>
36 #include <Image/Camera.hh>
37 #ifdef BIAS_HAVE_FFMPEG
38 # include <VideoSource/VideoSource_FFmpeg.hh>
40 #include <Base/Common/BIASpragma.hh>
68 vector<string> FileNames;
71 for (
int i = startCount; i< PictureCount; i++){
73 Name << Prefix << setfill(
'0') << setw(DigitCount) << i << Postfix;
74 FileNames.push_back(Name.str());
75 BIASDOUT(D_VSO_DISK,i<<
"\t"<< Name.str().c_str());
77 BIASDOUT(D_VSO_DISK,
"leaving VideoSource_Disk::OpenDevice(string .. )");
88 BIASDOUT(D_VSO_DISK,
"FileNames[0] : "<<FileNames[0]);
90 if (FileNames.empty()){
91 BEXCEPTION(
"VideoSource_Disk::OpenDevice(): empty argument vector");
95 #ifdef BIAS_HAVE_FFMPEG
96 if (Video_.OpenDevice(FileNames[0].c_str())==0)
99 Width_ = Video_.GetWidth();
111 int r = system(
"pwd");
112 if (r==-1){ BIASERR(
"error getting pwd"); }
113 BIASERR(
"unable to read "<<FileNames[0]);
120 attr.
Read(FileNames[0]);
131 for (vector<string>::const_iterator i = FileNames.begin();
132 i != FileNames.end();i++)
137 const char *fName2 =(*i).c_str();
140 if (i != FileNames.begin()){
143 BIASERR(
"VideoSource_Disk::OpenDevice() Image is "<<*i<<
144 " different from first image in sequence");
163 #ifdef BIAS_HAVE_FFMPEG
178 BIASERR(
"VideoSource_Disk::CloseDevice(): Grabbing is running, but closing anyway");
184 #ifdef BIAS_HAVE_FFMPEG
187 Video_.CloseDevice();
201 BIASERR(
"VideoSource_Disk::SetColorMode: source always gives the original"<<
202 " color mode of the saved files");
208 BIASDOUT(D_VSO_DISK,
"VideoSource_Disk::GrabSingle()");
210 #ifdef BIAS_HAVE_FFMPEG
218 BIASDOUT(D_VSO_DISK,
"GrabSingle() restarting with first file");
220 BEXCEPTION_NONFATAL(
"VideoSource_DISK: End of input. SetLoop(true) or "
222 BIASERR(
"VideoSource_DISK: End of input. SetLoop(true) or Rewind()");
228 BIASERR(
"VideoSource_Disk::GrabSingle(): VideoSource Object not active, use PreGrab()");
233 BIASERR(
"VideoSource_Disk::GrabSingle(): VideoSource Object is already grabbing()");
238 #ifdef BIAS_HAVE_FFMPEG
246 BEXCEPTION(
"VideoSource_Disk::GrabSingle(): Unable to read image: "
248 BIASERR(
"VideoSource_Disk::GrabSingle(): Unable to read image: "<<
FileNames_[ActiveFrame_]);
252 #ifdef BIAS_HAVE_FFMPEG
257 BIASERR(
"VideoSource_Disk::GrabSingle(): Reverse playing is not supported for videos yet");
262 bool eof = !Video_.GrabSingle(image);
269 if (!Video_.GrabSingle(image))
282 gettimeofday(&tv, NULL);
283 image.
SetTime(tv.tv_sec,tv.tv_usec);
290 BIASDOUT(D_VSO_DISK,
"GrabSingle() "<<
ActiveFrame_<<
" "<<
307 BIASDOUT(D_VSO_DISK,
"GrabSingle() restarting with first file");
317 BIASDOUT(D_VSO_DISK,
"leaving GrabSingle()");
354 BIASDOUT(D_VSO_DISK,
"VideoSource_Disk::GrabSingle()");
357 BIASERR(
"VideoSource_DISK: End of input. SetLoop(true) or Rewind()");
362 BIASERR(
"VideoSource_Disk::GrabSingle(): VideoSource Object not active, use PreGrab()");
367 BIASERR(
"VideoSource_Disk::GrabSingle(): VideoSource Object is already grabbing()");
375 BIASERR(
"VideoSource_Disk::GrabSingle(): Unable to read image: "<<
FileNames_[ActiveFrame_]);
383 gettimeofday(&tv, NULL);
384 image.
SetTime(tv.tv_sec,tv.tv_usec);
391 BIASDOUT(D_VSO_DISK,
"GrabSingle() "<<ActiveFrame_<<
" "<<
408 BIASDOUT(D_VSO_DISK,
"GrabSingle() restarting with first file");
418 BIASDOUT(D_VSO_DISK,
"leaving GrabSingle()");
454 #ifdef BUILD_IMAGE_USHORT
457 BIASDOUT(D_VSO_DISK,
"VideoSource_Disk::GrabSingle()");
460 BIASERR(
"VideoSource_DISK: End of input. SetLoop(true) or Rewind()");
465 BIASERR(
"VideoSource_Disk::GrabSingle(): VideoSource Object not active, use PreGrab()");
470 BIASERR(
"VideoSource_Disk::GrabSingle(): VideoSource Object is already grabbing()");
486 gettimeofday(&tv, NULL);
487 image.
SetTime(tv.tv_sec,tv.tv_usec);
494 BIASDOUT(D_VSO_DISK,
"GrabSingle() "<<
ActiveFrame_<<
" "<<
510 BIASDOUT(D_VSO_DISK,
"GrabSingle() restarting with first file");
519 BIASDOUT(D_VSO_DISK,
"leaving GrabSingle()");
556 BIASDOUT(D_VSO_DISK,
"VideoSource_Disk::GrabSingle()");
558 #ifdef BIAS_HAVE_FFMPEG
563 BIASERR(
"VideoSource_DISK: End of input. SetLoop(true) or Rewind()");
568 BIASERR(
"VideoSource_Disk::GrabSingle(): VideoSource Object not active, use PreGrab()");
573 BIASERR(
"VideoSource_Disk::GrabSingle(): VideoSource Object is already grabbing()");
581 BIASERR(
"VideoSource_Disk::GrabSingle(): Unable to read image: "<<
FileNames_[ActiveFrame_]);
586 BIASDOUT(D_VSO_DISK,
"GrabSingle() "<<ActiveFrame_<<
" "<<
602 BIASDOUT(D_VSO_DISK,
"GrabSingle() restarting with first file");
611 BIASDOUT(D_VSO_DISK,
"leaving GrabSingle()");
650 #ifdef BIAS_HAVE_FFMPEG
653 int64_t total = Video_.GetNumberOfFrames();
654 int64_t current = Video_.GetCurrentFrameNumber();
655 return total - current;
EColorModel
These are the most often used color models.
Defines a common interface to different devices.
virtual int GrabSingle(BIAS::Camera< unsigned char > &image)
unsigned int GetDepth() const
returns the bytes per channel, which is the sizeof(StorageType) Should match GetSizeDepth(GetStorageT...
unsigned int ActiveFrame_
BIAS::ImageBase::EColorModel ColorMode_
Color mode used by camera.
float BytesPerPixel_
BytesPerPixel cannot be int (e.g. it is 1.5 for YUV420p)
unsigned int GetWidth() const
virtual ~VideoSource_Disk()
bool CompleteInitialized_
Complete_initialized_ is set when OpenDevice(), UseChannel() etc. are done.
class BIASImageBase_EXPORT Image
std::string Identifier_
Verbose camera descriptor.
bool Grabbing_
Grabbing flag is set and unset in GrabSingle() methods.
virtual int OpenDevice()
selects the first available device to open (e.g.
static int GetSizeUnits(const enum BIAS::ImageBase::EColorModel &colormodel)
get the number of (packed) data values of color model E.g: CM_Grey : 1 CM_YUYV422 : 2 packs 3 channel...
float FramesPerSecond_
Capturing framerate.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
color values, 3 channels, order: red,green,blue
bool FrameCounterAsTimeStamp_
void SetDebugLevel(const long int lv)
unsigned int GetHeight() const
int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)
virtual int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)
bool Active_
Active flag is set in PreGrab() und unset in PostGrab()
int Read(const std::string &filename)
main entry routine to read all EXIF tags from the header of image file.
double GetRealTime() const
return real time (=wall time clock) in usec JW For Win32: real-time is measured differently from user...
void SetUID(const BIAS::UUID &id)
enum EColorModel GetColorModel() const
contains all atribute info and values of e.g. a file.
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
std::vector< std::string > FileNames_
void InitExifTags()
initialize me vector with all known EXIF tags
void SetTime(unsigned long long int sec, unsigned long long int usec)
Set time and ensure correct format (seconds and useconds after 'sec')
int SetColorMode(BIAS::ImageBase::EColorModel mode)
std::string GetIdentifier()
combine Make, Model and focallength to one special identifier
This is the base class for images in BIAS.
int ParseMetaData(bool bUse2x64bitTS=true)
After ImageIO::Load() operated on AppData_, this method fills P_, Timestamp, DC_*, ...
unsigned int GetNumFramesRemaining() const
static UUID GenerateUUID(const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
static function which simply produces a uuid and returns
int PostGrab()
Stop anything started in PreGrab()