Ask Your Question

Wei's profile - activity

2016-11-27 05:28:40 -0500 received badge  Notable Question (source)
2016-11-27 05:28:40 -0500 received badge  Famous Question (source)
2016-07-14 23:34:57 -0500 commented question Use Optical flow to track Feature

It seems to be able to perform faster.

2016-06-04 05:33:32 -0500 asked a question Use Optical flow to track Feature

I use calcOpticalFlowPyrLK() to track keypoint in feature ,but the calcOpticalFlowPyrLK() is unstable. How optimize it?
TrackOpticalFlow function:

static vector<KeyPoint> currPoints,predictPoints;
void trackingOpticalFlow(const cv::Mat sceneMat, const vector<KeyPoint> sceneKeyPoint, vector<KeyPoint> *predictKeyPoint){
    if( sceneMat.empty() || sceneKeyPoint.empty()) return;
    vector<uchar> status;
    vector<float> err;
    vector<Point2f> pt1,pt2;
    vector<Point2f> transPt1,transPt2;
    cv::Mat sceneMat_gray;

    cv::Size winSize = cv::Size(9, 9);
    int maxLevel = 21;
    cv::TermCriteria terminationCriteria = cv::TermCriteria( CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 20, 0.03);

    this->getGrayMat(sceneMat, sceneMat_gray);

    if(m_trackPrev.empty()){
        sceneMat_gray.copyTo(m_trackPrev);
        return;
    }

    if(prevPyr.empty()){
        cv::buildOpticalFlowPyramid(m_trackPrev, prevPyr, winSize, maxLevel, true);
    }

    KeyPoint::convert(sceneKeyPoint, pt1);
    transPt1.clear();
    transPt1 = pt1;

    cv::buildOpticalFlowPyramid(sceneMat_gray, nextPyr, winSize, maxLevel, true);
    cv::calcOpticalFlowPyrLK(prevPyr, nextPyr, transPt1, transPt2, status, err, winSize, maxLevel, terminationCriteria, CV_LKFLOW_PYR_B_READY, 1e-10);

    std::vector<cv::Point2f> trackedPts;
    for (size_t i=0; i<status.size(); i++)
    {
        if (status[i] && transPt1.size()>i && norm(transPt2[i] - transPt1[i]) <= 100)
        {
            trackedPts.push_back(transPt2[i]);
        }
    }

    pt2.clear();
    pt2 = transPt2;


    KeyPoint::convert(pt2, *predictKeyPoint);
    swap(m_trackPrev, sceneMat_gray);
    prevPyr.swap(nextPyr);
}

Input mat in video:

void runTrack(cv::Mat sceneMat){    
   cv::Mat sceneMatGray;
   Mat sceneDescriptor;
   this->getGrayMat(sceneMat, sceneMatGray);
   if(!m_isTrack){
       this->detectFeatures(sceneMatGray, &m_trackPreKeypoints, &sceneDescriptor);

       if(m_trackPreKeypoints.empty() || sceneDescriptor.empty()) {
            m_isDetectObject = false;
            return;
       }else{
            this->matchByKnn(m_patternDescriptor, sceneDescriptor, &m_trackMatches);
       }

       if( m_trackMatches.size() < 4){
            m_isDetectObject = false;
            return;
       }

   }else{

       vector<KeyPoint> outKeypoints;
       outKeypoints.clear();
       this->trackingOpticalFlow(sceneMatGray, m_trackPreKeypoints, &outKeypoints);
       if(outKeypoints.empty()) return;


       for(int i=0;i< m_trackPreKeypoints.size();i++)
             cv::circle(sceneMat, m_trackPreKeypoints[i].pt, 2, CV_RGB(255, 0, 0));

       for(int i=0;i<outKeypoints.size();i++)
              cv::circle(sceneMat, outKeypoints[i].pt, 2, CV_RGB(0, 0, 255));

        m_trackPreKeypoints.swap(outKeypoints);

   }

   cv::Mat homography;
   this->getHomography(m_patternKeypoints, m_trackPreKeypoints, m_trackMatches, &homography);
}
2016-04-15 01:48:03 -0500 received badge  Popular Question (source)
2016-04-15 01:35:32 -0500 received badge  Editor (source)
2016-04-15 01:34:37 -0500 asked a question build opencv_contrib module for iOS, opencv_xfeatures2d fail

I build framework for OpenCV with opencv_contrib module. OpenCV 3.1 Xcode 7.2.1

I refer http://answers.opencv.org/question/40... . but link is not effective. try:

python build_framework.py --contrib opencv_contrib ios

The error:

** BUILD FAILED **


The following build commands failed:
    CompileC platforms/ios/ios/build/armv7-iPhoneOS/modules/xfeatures2d/OpenCV.build/Release-iphoneos/opencv_xfeatures2d.build/Objects-normal/armv7/sift.o /Users/admin/Desktop/OpenCV_for_iOS/opencv_contrib/modules/xfeatures2d/src/sift.cpp normal armv7 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
ERROR: Command '['xcodebuild', 'IPHONEOS_DEPLOYMENT_TARGET=6.0', 'ARCHS=armv7', '-sdk', 'iphoneos', '-configuration', 'Release', '-parallelizeTargets', '-jobs', '4', '-target', 'ALL_BUILD', 'build']' returned non-zero exit status 65
Traceback (most recent call last):
  File "build_framework.py", line 87, in build
    self._build(outdir)
  File "build_framework.py", line 81, in _build
    self.buildOne(t[0], t[1], mainBD, cmake_flags)
  File "build_framework.py", line 139, in buildOne
    execute(buildcmd + ["-target", "ALL_BUILD", "build"], cwd = builddir)
  File "build_framework.py", line 34, in execute
    retcode = check_call(cmd, cwd = cwd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['xcodebuild', 'IPHONEOS_DEPLOYMENT_TARGET=6.0', 'ARCHS=armv7', '-sdk', 'iphoneos', '-configuration', 'Release', '-parallelizeTargets', '-jobs', '4', '-target', 'ALL_BUILD', 'build']' returned non-zero exit status 65
2015-12-29 00:05:30 -0500 received badge  Enthusiast
2015-12-28 22:10:14 -0500 asked a question The FREAK not fount in opencv2.framework(OpenCV3.1)

The FREAK not find in opencv2/features2D.

OpenCV 3.1 release message for iOS: The iOS framework (opencv2.framework) can now be configured to include both opencv and opencv_contrib functionality.

How to use opencv_contrib ?

2015-12-24 22:39:29 -0500 asked a question Error: build OpenCV3.0 + opencv_contrib in Mac

build OpenCV + opencv_contrib I refer this net: http://xfanzone.me/opencv-for-ios-en.... and enter code in Terminal: cmake -DOPENCV_EXTRA_MODULES_PATH=/Users/admin/OpenCV_for_iOS/opencv_contrib/modules /Users/admin/OpenCV_for_iOS/opencv-master.

Terminal export:


-- GUI: -- QT: NO -- Cocoa: YES -- OpenGL support: NO

-- VTK support: NO

-- Media I/O: -- ZLib: build (ver 1.2.8) -- JPEG: build (ver 90) -- WEBP: build (ver 0.3.1) -- PNG: build (ver 1.6.19) -- TIFF: build (ver 42 - 4.0.2) -- JPEG 2000: build (ver 1.900.1) -- OpenEXR: build (ver 1.7.1)

-- GDAL: NO

-- Video I/O: -- DC1394 1.x: NO -- DC1394 2.x: NO -- FFMPEG: NO -- codec: NO -- format: NO -- util: NO -- swscale: NO -- resample: NO -- gentoo-style: NO -- GStreamer: NO -- OpenNI: NO -- OpenNI PrimeSensor Modules: NO -- OpenNI2: NO -- PvAPI: NO -- GigEVisionSDK: NO -- QuickTime: NO -- QTKit: YES -- V4L/V4L2: NO/NO -- XIMEA: NO

-- gPhoto2: NO

-- Parallel framework: GCD

-- Other third-party libraries: -- Use IPP: 9.0.1 [9.0.1] -- at: /Users/admin/Desktop/ChenWei-workspace/OpenCV_for_iOS/opencv-master/3rdparty/ippicv/unpack/ippicv_osx -- Use IPP Async: NO -- Use VA: NO -- Use Intel VA-API/OpenCL: NO -- Use Eigen: NO -- Use Cuda: NO

-- Use OpenCL: YES

-- OpenCL: -- Version: static -- libraries: -framework OpenCL -- Use AMDFFT: NO

-- Use AMDBLAS: NO

-- Python 2: -- Interpreter: /usr/bin/python2.7 (ver 2.7.10) -- Libraries: /usr/lib/libpython2.7.dylib (ver 2.7.10) -- numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include (ver 1.8.0rc1)

-- packages path: lib/python2.7/site-packages

-- Python 3:

-- Interpreter: NO

-- Python (for build): /usr/bin/python2.7

-- Java: -- ant: NO -- JNI: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/JavaVM.framework/Headers /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/JavaVM.framework/Headers /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/JavaVM.framework/Headers -- Java wrappers: NO

-- Java tests: NO

-- Matlab:

-- mex: NO

-- Documentation: -- Doxygen: NO

-- PlantUML: NO

-- Tests and samples: -- Tests: YES -- Performance tests: YES

-- C/C++ Examples: NO

-- Install path: /usr/local

-- cvconfig.h is in: /Users/admin/Desktop/ChenWei-workspace/OpenCV_for_iOS/opencvframeworkbuild

-- -----------------------------------------------------------------

-- Configuring done -- Generating done -- Build files have been written to: /Users/admin/Desktop/ChenWei-workspace/OpenCV_for_iOS/opencv


and then . make -j Error in 80%


/usr/local/include/opencv2/core/mat.hpp:58:13: error: incomplete type 'cv::Mat' named in nested name specifier inline void Mat::initEmpty() ^~~~~

/usr/local/include/opencv2/core/mat.hpp:67:8: error: incomplete type 'cv::Mat' named in nested name specifier inline Mat::Mat() : size(&rows) ^~~~~ /usr/local/include/opencv2/core/mat.hpp:72:8: error: incomplete type 'cv::Mat' named in nested name specifier inline Mat::Mat(int _rows, int _cols, int _type) : size(&rows)

/usr/local/include/opencv2/core/mat.hpp:78:8: error: incomplete type 'cv::Mat' named in nested name specifier inline Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) : size(&rows)

/usr/local/include/opencv2/core/mat.hpp:78:8: error: incomplete type 'cv ...

(more)
2015-09-15 09:21:15 -0500 commented question How install OpenCV in CodeBlocks?

Thank. The error is disappeared. But other error: ||=== Build: all in OpenCV (compiler: GNU GCC Compiler) ===| C:\opencv\sources\modules\core\src\system.cpp||In function 'BOOL cv::DllMain(HINSTANCE, DWORD, LPVOID)':| C:\opencv\sources\modules\core\src\system.cpp|1013|warning: no previous declaration for 'BOOL cv::DllMain(HINSTANCE, DWORD, LPVOID)' [-Wmissing-declarations]| C:\opencv\sources\modules\videoio\src\cap_dshow.cpp|122|error: 'struct IEnumPIDMap' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]| C:\opencv\sources\modules\videoio\src\cap_dshow.cpp|139|error: 'struct IMPEG2PIDMap' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|

2015-09-15 05:25:45 -0500 asked a question How install OpenCV in CodeBlocks?

My system is Window 7 64 bit.I want to install in CodeBlocks. However, I try this http://jatb181.blogspot.tw/2014/06/in... ,but I use Cmake to build Opencv3.0 fail. It show not find -lRunTmChk and ||=== Build: all in OpenCV (compiler: GNU GCC Compiler) ===| C:\opencv\sources\modules\core\src\matrix.cpp||In function 'bool cv::ocl_reduce(cv::InputArray, cv::OutputArray, int, int, int, int, int)':| C:\opencv\sources\modules\core\src\matrix.cpp|3536|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]| C:\opencv\sources\modules\core\src\system.cpp||In function 'BOOL cv::DllMain(HINSTANCE, DWORD, LPVOID)':| C:\opencv\sources\modules\core\src\system.cpp|1013|warning: no previous declaration for 'BOOL cv::DllMain(HINSTANCE, DWORD, LPVOID)' [-Wmissing-declarations]| ld.exe||cannot find -lRunTmChk| modules\core\CMakeFiles\opencv_core.dir\build.make|1286|recipe for target 'bin/libopencv_core300.dll' failed| CMakeFiles\Makefile2|1654|recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed| C:\opencvdll\Makefile|148|recipe for target 'all' failed| ||=== Build failed: 4 error(s), 2 warning(s) (5 minute(s), 31 second(s)) ===|

image: image description