You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.4 KiB
98 lines
2.4 KiB
#ifndef __VIDEO_INPUT_HEADERS__
|
|
#define __VIDEO_INPUT_HEADERS__
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/time.h>
|
|
#include <sys/types.h>
|
|
#include <linux/types.h>
|
|
#include <opencv2/opencv.hpp>
|
|
#include <pthread.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "video_proc.h"
|
|
|
|
#define _NOAUDIO_
|
|
|
|
#define _VIN_DefaultWidth 640
|
|
#define _VIN_DefaultHeight 480
|
|
#define ARM_BR_NOW 0
|
|
#define _VIN_DefaultQueueSize 15
|
|
#define _VIN_DefaultFPS 15
|
|
|
|
typedef std::vector< cv::Mat* > _FrameQueue;
|
|
|
|
typedef enum{
|
|
VI_NO_SAVE_MODE = 0,
|
|
VI_IMAGE_SEQUENCE = 1,
|
|
VI_MJPEG_FILE = 2,
|
|
VI_MPEG1_FILE = 3,
|
|
VI_MPEG2_FILE = 4,
|
|
VI_MP4_FILE = 5
|
|
} _VI_SAVE_MODE;
|
|
|
|
|
|
typedef enum{
|
|
VI_CREATED = 0,
|
|
VI_INIT_OK = 1,
|
|
VI_DEVICE_OK = 2,
|
|
VI_SETTINGS_OK = 3,
|
|
VI_MEMORY_OK = 4,
|
|
VI_STREAM_OK = 5,
|
|
VI_WORKING_OK = 6,
|
|
VI_STOPED = 7,
|
|
VI_RESTARTING = 8
|
|
} _VI_THREAD_STATUS;
|
|
|
|
class _VideoInput{
|
|
protected:
|
|
_VI_THREAD_STATUS m_bStatus;
|
|
int m_nWidth;
|
|
int m_nHeight;
|
|
bool m_bSizeIsAutomatic;
|
|
int m_nFramesPerSecond;
|
|
char m_sStoragePath[1024];
|
|
char m_sSaveItemName[128];
|
|
_VP_Pool m_vImageProcessors;
|
|
_FrameQueue m_vFrameQueue;
|
|
int m_nQueueDepth;
|
|
bool m_bSaveStream;
|
|
bool m_bPermanentSave;
|
|
_VI_SAVE_MODE m_eSaveMode;
|
|
int m_nSaveCounter;
|
|
cv::VideoWriter *m_pVideoWriter;
|
|
long long m_llFrameCounter;
|
|
pthread_mutex_t m_sInputMmutex;
|
|
pthread_t m_sInputThread;
|
|
|
|
virtual void m_fInputProc( void ){
|
|
m_bStatus = VI_WORKING_OK;
|
|
while( m_bStatus == VI_WORKING_OK ){
|
|
sleep(1);
|
|
};
|
|
pthread_exit( NULL );
|
|
};
|
|
static void *m_fStarterProc( void *arg );
|
|
|
|
void saveQueueFrame( void );
|
|
void processingImage( cv::Mat *pFrame );
|
|
public:
|
|
_VideoInput();
|
|
~_VideoInput();
|
|
bool pushFrame( cv::Mat *pFrame );
|
|
cv::Mat *getCurrent( void );
|
|
bool alarm( int forwardLength = ARM_BR_NOW, int backwardReserve = ARM_BR_NOW );
|
|
bool setStorage( char *Path, _VI_SAVE_MODE mode = VI_IMAGE_SEQUENCE, bool permanent = false );
|
|
bool attachImageProcessing( _VideoProcessor *Proc );
|
|
bool startInput( void );
|
|
bool stopInput( void );
|
|
};
|
|
|
|
|
|
|
|
#endif
|