OpenCV - yszheda/wiki GitHub Wiki

CV::Point

Ptr

Mat

cv::Mat mask = M == 0;
M.setTo(0.5, mask);

array to Mat

Mat to vector

// Pointer to the i-th row
const double* p = mat.ptr<double>(i);

// Copy data to a vector.  Note that (p + mat.cols) points to the
// end of the row.
std::vector<double> vec(p, p + mat.cols);

Mat.at

Mat_<double> M(20,20);
for(int i = 0; i < M.rows; i++)
    for(int j = 0; j < M.cols; j++)
        M(i,j) = 1./(i+j+1);
Mat E, V;
eigen(M,E,V);
cout << E.at<double>(0,0)/E.at<double>(M.rows-1,0);

load Mat

Depth Image

CV::sum

Time Measurement

e1 = cv2.getTickCount()
# your code execution
e2 = cv2.getTickCount()
time = (e2 - e1)/ cv2.getTickFrequency()
struct CVTimer {
    double pcFrequency;
    double start;
    double end;

    CVTimer()
    {
        pcFrequency = static_cast<double>(cvGetTickFrequency() * 1000);
        restart();
    }

    ~CVTimer()
    {
    }

    void restart()
    {
        start = static_cast<double>(cvGetTickCount());
    }

    double elapsedTime()
    {
        end = static_cast<double>(cvGetTickCount());
        return (end - start) / pcFrequency;
    }
};				/* ----------  end of struct OpenCVTimer  ---------- */

typedef struct CVTimer CVTimer;

pyramid resize

VideoCapture

'CAP_PROP_FRAME_COUNT' was not declared in this scope

contour

blob detection

fillConvexPoly

convolution / filter2D

IO

split

threshold

getOptimalDFTSize

minAreaRect

Affine Transformations

Image rectification

initUndistortRectifyMap

remap

XML / YAML

Makefile

multithread

parallel_for_

  class LambdaParallLoopBody : public cv::ParallelLoopBody {
    private:
      std::function<void(const cv::Range&)> functor_;
    public:
      LambdaParallLoopBody(std::function<void(const cv::Range&)> functor):
        functor_(functor) {}
      virtual void operator() (const cv::Range& range) const {
        functor_(range);
      }
  };

  inline void parallel_for(const cv::Range& range, std::function<void(const cv::Range&)> functor, double nstripes = -1.) {
    cv::parallel_for_(range, LambdaParallLoopBody(functor), nstripes);
  }

CUDA

Trouble shooting

Corrupt JPEG data: 1 extraneous bytes before marker 0x0d

drawContours: OpenCV Error: Assertion failed (i < 0) in getMat

⚠️ **GitHub.com Fallback** ⚠️