visageSDK
AndroidImageCapture.cpp
1 #include "AndroidImageCapture.h"
2 #include <android/log.h>
3 
4 #define LOG_TAG "AndroidImageCapture"
5 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
6 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
7 
8 namespace VisageSDK
9 {
10 
12 {
13  pts = 0;
14 }
15 
16 AndroidImageCapture::AndroidImageCapture(int width, int height, int format)
17 {
18  int nChannels;
19  switch (format) {
20  case VISAGE_FRAMEGRABBER_FMT_RGB:
21  // fall-through
22  case VISAGE_FRAMEGRABBER_FMT_BGR:
23  nChannels = 3;
24  break;
25  case VISAGE_FRAMEGRABBER_FMT_LUMINANCE:
26  // fall-through
27  default:
28  nChannels = 1;
29  break;
30  }
31  buffer = vsCreateImage(vsSize(width, height), VS_DEPTH_8U,nChannels);
32  pts = 0;
33  this->width = width;
34  this->height = height;
35 }
36 
38 {
39  // cleaning up
40  vsReleaseImage(&buffer);
41 }
42 
43 void AndroidImageCapture::WriteFrame(unsigned char* imageData, int width, int height)
44 {
45  this->width = width;
46  this->height = height;
47  memcpy(buffer->imageData, imageData, buffer->imageSize);
48 }
49 
51 {
52  timeStamp = pts++;
53  return buffer;
54 }
55 }
char * imageData
Pointer to aligned image data.
void WriteFrame(unsigned char *imageData, int width, int height)
Method for writing imageData to buffer object.
VsImage * GrabFrame(long &timeStamp)
This function is called to get the frame to process.
int imageSize
Image data size in bytes (==image->height*image->widthStep in case of interleaved data) ...
Namespace.
Definition: android_header.h:1
Image store container.