#include "vlfeat.h" // filter parameters static const int FKERNELSIZE = 7; //7// for gaussian blur static const float FSTDDEV = 1.5; static const int FBLOCKSIZE = 47;// 51; //47// for adaptive threshold static const int FC = -5; //-5 /* ideatab a2109a android 4.1.1 kernel 3.1.10 bld num: a2109a_a411_03_13_121126_il hw info: 0.hy16 */ // A33_U70_U708HC_1511235_20160820 // https://cloud.mail.ru/public/e4a01c0091ae/Allwinner%20A33 vlfeatDetector::vlfeatDetector() : basicVideoAnalyzer() { m_iWidth = 0; m_iHeight = 0; m_bPIP = false; type = VA_FEAT_DETECT; //m_pCortexImage = NULL; m_oFilter = new filterImage(FKERNELSIZE, FSTDDEV, FBLOCKSIZE, FC); m_pVlDsiftFilter = NULL; m_nOldKeyPoints = 0; m_nNewKeyPoints = 0; m_pOldKeyPoints = NULL; m_pNewKeyPoints = NULL; //if( vl_get_state()->malloc_func == NULL){ vl_set_simd_enabled(true); vl_set_alloc_func(malloc, realloc, calloc, free); //}; int tCount = gpu::getCudaEnabledDeviceCount(); if (tCount){ gpu::setDevice(0); }; }; vlfeatDetector::~vlfeatDetector(){ delete(m_oFilter); if (m_nOldKeyPoints)free(m_pOldKeyPoints); if (m_nNewKeyPoints)free(m_pNewKeyPoints); if (m_pVlDsiftFilter!=NULL)vl_dsift_delete(m_pVlDsiftFilter); //if (m_pCortexImage != NULL)delete(m_pCortexImage); }; /* unsigned int root(unsigned int x){ unsigned int a,b; b = x; a = x = 0x3f; x = b/x; a = x = (x+a)>>1; x = b/x; a = x = (x+a)>>1; x = b/x; x = (x+a)>>1; return(x); }; */ bool vlfeatDetector::m_fImageAnalyzer(Mat &Picture){ if( Picture.empty() ) return false; if (m_pVlDsiftFilter == NULL){ m_iWidth = Picture.cols; m_iHeight = Picture.rows; m_pVlDsiftFilter = vl_dsift_new_basic(m_iWidth, m_iHeight, DSIFT_STEP_X, DSIFT_BIN_SIZE); }; if (m_pVlDsiftFilter == NULL) return false; m_oFilter->filter(Picture); //if (m_pCortexImage==NULL){ // m_pCortexImage = new cortexImage(&m_oFilter->filterFrame()); //return false; //} else m_pCortexImage->fillFromMat(&m_oFilter->filterFrame()); free( m_pOldKeyPoints ); m_nOldKeyPoints = 0; if (m_nNewKeyPoints > 0){ //m_pOldKeyPoints = (VlDsiftKeypoint*)calloc(m_nNewKeyPoints, sizeof(VlDsiftKeypoint)); //memccpy(m_pOldKeyPoints, m_pNewKeyPoints, m_nNewKeyPoints, sizeof(VlDsiftKeypoint)); m_pOldKeyPoints = m_pNewKeyPoints; m_nOldKeyPoints = m_nNewKeyPoints; }; //vl_dsift_process(m_pVlDsiftFilter, m_pCortexImage->data); m_nNewKeyPoints = vl_dsift_get_keypoint_num(m_pVlDsiftFilter); m_pNewKeyPoints = (VlDsiftKeypoint*)vl_dsift_get_keypoints(m_pVlDsiftFilter); //vl_dsift_get_descriptors(m_pVlDsiftFilter); return true; }; void vlfeatDetector::markup(Mat &Picture){ m_mBufferProtectorMutex.lock(); //if (!m_oMat.empty()) { // cvtColor(m_oMat, Picture, CV_GRAY2BGR); //}; //for (int i = 0; i < m_aGoodMatches.matches.size(); i++){ // int a, b; // a = m_aGoodMatches.matches[i].trainIdx; // b = m_aGoodMatches.matches[i].queryIdx; // if (a < m_aOldKeyPoints.size() && b < m_aNewKeyPoints.size()){ // //circle(Picture, m_aOldKeyPoints[a].pt, 5, Scalar(0, 255, 0), 1, 8); // //circle(Picture, m_aNewKeyPoints[b].pt, 5, Scalar(255, 0, 255), 1, 8); // line(Picture, m_aOldKeyPoints[a].pt, m_aNewKeyPoints[b].pt, Scalar(255, 255, 128), 2); // }; //}; for (int i = 0; ifilterFrame().empty()){ resize(m_oFilter->filterFrame(), resizedSrc, Size(160, 120), 0.0, 0.0, INTER_AREA); subView = Picture(Rect((Picture.cols - 510), 50 + 120, 160, 120)); cvtColor(resizedSrc, convertedSrc, CV_GRAY2BGR); convertedSrc.copyTo(subView); }; if (!m_oFilter->gaussianFrame().empty()){ resize(m_oFilter->gaussianFrame(), resizedSrc, Size(160, 120), 0.0, 0.0, INTER_AREA); subView = Picture(Rect((Picture.cols - 340), 50 + 120, 160, 120)); cvtColor(resizedSrc, convertedSrc, CV_GRAY2BGR); convertedSrc.copyTo(subView); }; if (!m_oFilter->thresholdFrame().empty()){ resize(m_oFilter->thresholdFrame(), resizedSrc, Size(160, 120), 0.0, 0.0, INTER_AREA); subView = Picture(Rect((Picture.cols - 170), 50 + 120, 160, 120)); cvtColor(resizedSrc, convertedSrc, CV_GRAY2BGR); convertedSrc.copyTo(subView); }; }; m_mBufferProtectorMutex.unlock(); };