Operator Console
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FileAcquisition Class Reference

Another class for loading an image file that loads into the critical buffer m_frame inherited from class ImageAcquisition. More...

#include <FileAcquisition.h>

Inheritance diagram for FileAcquisition:
[legend]

Public Member Functions

 FileAcquisition (void)
 
 ~FileAcquisition (void)
 
bool CaptureFrame ()
 image is already in m_frame, so there's nothing to do More...
 
bool Close ()
 
bool Init (int width, int height, const char *filename)
 Initializes the buffers inherited from class ImageAcquisition with 2 bytes per pixel. More...
 
bool Open ()
 
void SetFile (const CString filePathName)
 
 FileAcquisition (void)
 
 ~FileAcquisition (void)
 
bool CaptureFrame ()
 image is already in m_frame, so there's nothing to do More...
 
bool Close ()
 
bool Init (int width, int height, const char *filename)
 
bool Open ()
 
void SetFile (const CString filePathName)
 
- Public Member Functions inherited from ImageAcquisition
 ImageAcquisition (void)
 
virtual ~ImageAcquisition (void)
 
void GetFrame (void *buf)
 
virtual bool Init (int width, int height, int bytesPerPixel=4)
 may be overridden, but be sure to call parent function also More...
 
unsigned int BytesPerFrame ()
 
unsigned int PixelsPerFrame ()
 
int GetHeight ()
 
CString & GetInfo ()
 
int GetWidth ()
 
void SetHeight (int height)
 
void SetWidth (int width)
 
 ImageAcquisition (void)
 
virtual ~ImageAcquisition (void)
 
void GetFrame (void *buf)
 
virtual bool Init (int width, int height, int bytesPerPixel=4)
 may be overridden, but be sure to call parent function also More...
 
unsigned int BytesPerFrame ()
 
unsigned int PixelsPerFrame ()
 
int GetHeight ()
 
CString & GetInfo ()
 
int GetWidth ()
 
void SetHeight (int height)
 
void SetWidth (int width)
 

Protected Member Functions

bool LoadFile ()
 Loads an image file through a filestream and then copies into m_buf. More...
 
bool LoadFile ()
 

Protected Attributes

CString m_filename
 fully-qualified image file name More...
 
- Protected Attributes inherited from ImageAcquisition
CriticalBuf m_frame
 shared memory to hold copy of current frame More...
 
int m_width
 width of image in pixels More...
 
int m_height
 height of image in pixels More...
 
unsigned int m_numBytes
 number of bytes in a frame More...
 
unsigned int m_numPixels
 number of pixels in a frame More...
 
CString m_logMsg
 error or information message More...
 
void * m_buf
 buffer to capture into More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ImageAcquisition
static UINT __cdecl ThreadProc (LPVOID param)
 
static UINT __cdecl ThreadProc (LPVOID param)
 
- Public Attributes inherited from ImageAcquisition
int m_source_ID
 The source ID for acquire_image() that indicates what type of device is in use. More...
 
int m_device_ID
 [Used Epiphan only]: indicates from which of the two sources to capture More...
 
std::string m_ini_file
 The fully-qualified name (including full path) of an Imatest INI file. More...
 

Detailed Description

Another class for loading an image file that loads into the critical buffer m_frame inherited from class ImageAcquisition.

Constructor & Destructor Documentation

FileAcquisition::FileAcquisition ( void  )
29 {
30  m_numPixels = 0;
31  m_buf = NULL;
32  m_filename.Empty();
33 }
unsigned int m_numPixels
number of pixels in a frame
Definition: ImageAcquisition.h:56
void * m_buf
buffer to capture into
Definition: ImageAcquisition.h:58
CString m_filename
fully-qualified image file name
Definition: FileAcquisition.h:41
FileAcquisition::~FileAcquisition ( void  )
37 {
38 }
FileAcquisition::FileAcquisition ( void  )
FileAcquisition::~FileAcquisition ( void  )

Member Function Documentation

bool FileAcquisition::CaptureFrame ( )
inlinevirtual

image is already in m_frame, so there's nothing to do

Implements ImageAcquisition.

bool FileAcquisition::CaptureFrame ( )
inlinevirtual

image is already in m_frame, so there's nothing to do

Implements ImageAcquisition.

bool FileAcquisition::Close ( )
virtual

Implements ImageAcquisition.

62 {
63  return true;
64 }
bool FileAcquisition::Close ( )
virtual

Implements ImageAcquisition.

bool FileAcquisition::Init ( int  width,
int  height,
const char *  filename 
)
bool FileAcquisition::Init ( int  width,
int  height,
const char *  filename 
)

Initializes the buffers inherited from class ImageAcquisition with 2 bytes per pixel.

Returns
Returns TRUE if allocation is successful.

References ImageAcquisition::Init().

Referenced by COperatorConsoleApp::InitBlemishAcq(), and COperatorConsoleApp::InitSFRplusAcq().

45 {
46  bool result;
47 
48  m_filename = filename;
49  result = ImageAcquisition::Init(width, height, 2);
50 
51  return result;
52 }
virtual bool Init(int width, int height, int bytesPerPixel=4)
may be overridden, but be sure to call parent function also
Definition: ImageAcquisition.cpp:43
width
Definition: calculation_checks.m:1
height
Definition: calculation_checks.m:2
CString m_filename
fully-qualified image file name
Definition: FileAcquisition.h:41

Here is the call graph for this function:

Here is the caller graph for this function:

bool FileAcquisition::LoadFile ( )
protected
bool FileAcquisition::LoadFile ( )
protected

Loads an image file through a filestream and then copies into m_buf.

Optionally, m_buf can be copied into the critical buffer, m_frame.

Returns
Returns TRUE if the file is loaded into m_buf, FALSE otherwise.
71 {
72  bool success = false;
73  ifstream::pos_type size;
74  ifstream filestream(m_filename, ios::binary);
75 
76  if (!filestream.is_open())
77  {
78  m_logMsg.Format("%s: Unable to open image file '%s'", __FUNCTION__, m_filename);
79  }
80  else
81  {
82  filestream.seekg(0, ios::end); // Determine length of file
83  size = filestream.tellg();
84  filestream.seekg(0, ios::beg); // rewind
85 
86  //
87  // Make sure that our buffer is large enough to hold the file
88  //
89  if (m_numBytes != (unsigned int)size)
90  {
91  m_logMsg.Format("%s: '%s' is too big for buffer", __FUNCTION__, m_filename);
92  }
93  else if (m_buf == NULL)
94  {
95  m_logMsg.Format("%s: m_buf is NULL", __FUNCTION__);
96  }
97  else
98  {
99  //
100  // Read the contents of the file into m_buf, closing the file when done
101  //
102  filestream.read((char *)m_buf, size);
103  filestream.close();
104  m_logMsg.Format("%s: Read in %d bytes", __FUNCTION__, (long)size);
105 #if 0
106 
107  m_frame.Set(m_buf); // this copies m_buf to shared memory that gets accessed by GetFrame()
108 #endif
109  success = true;
110  }
111  }
112 
113  return success;
114 }
CriticalBuf m_frame
shared memory to hold copy of current frame
Definition: ImageAcquisition.h:52
void Set(void *buf)
Definition: CriticalBuf.cpp:74
unsigned int m_numBytes
number of bytes in a frame
Definition: ImageAcquisition.h:55
void * m_buf
buffer to capture into
Definition: ImageAcquisition.h:58
CString m_logMsg
error or information message
Definition: ImageAcquisition.h:57
CString m_filename
fully-qualified image file name
Definition: FileAcquisition.h:41
bool FileAcquisition::Open ( )
virtual

Implements ImageAcquisition.

bool FileAcquisition::Open ( )
virtual

Implements ImageAcquisition.

Referenced by COperatorConsoleApp::InitBlemishAcq(), and COperatorConsoleApp::InitSFRplusAcq().

55 {
56  bool result = LoadFile();
57 
58  return result;
59 }
bool LoadFile()
Loads an image file through a filestream and then copies into m_buf.
Definition: FileAcquisition.cpp:70

Here is the caller graph for this function:

void FileAcquisition::SetFile ( const CString  filePathName)
inline

References m_filename.

35 {m_filename = filePathName;}
CString m_filename
fully-qualified image file name
Definition: FileAcquisition.h:41
void FileAcquisition::SetFile ( const CString  filePathName)
inline

References m_filename.

35 {m_filename = filePathName;}
CString m_filename
fully-qualified image file name
Definition: FileAcquisition.h:41

Member Data Documentation

CString FileAcquisition::m_filename
protected

fully-qualified image file name

Referenced by SetFile().


The documentation for this class was generated from the following files: