Skip to content

Instantly share code, notes, and snippets.

@akihikoy
Created February 18, 2016 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akihikoy/c951accf27725951c31e to your computer and use it in GitHub Desktop.
Save akihikoy/c951accf27725951c31e to your computer and use it in GitHub Desktop.
OpenCV matrix type example
#include <opencv2/core/core.hpp>
#include <iostream>
using namespace std;
#define print(var) std::cout<<#var"= "<<endl<<(var)<<std::endl
int main(int argc, char**argv)
{
cv::Mat m1(3,3,CV_8UC1), m2(3,3,CV_8UC1), m3;
m1= (cv::Mat_<unsigned char>(3,3)<<1,0,1, 0,0,1, 0,1,1);
m2= (cv::Mat_<unsigned char>(3,3)<<0,1,1, 1,0,1, 0,1,0);
print(m1);
print(m2);
print(m1-m2);
print(m1&m2);
bitwise_xor(m1,m2,m3);
print(m3);
print(sum(m3)[0]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment