Beispiel #1
0
 //
 // showPropertiesOfMat
 //
 //   ...displays all properties of specified Mat.
 //
 void showPropertiesOfMat (const cv::Mat &src_mat)
 {
   // 行数
   std::cout << "rows:" << src_mat.rows <<std::endl;
   // 列数
   std::cout << "cols:" << src_mat.cols << std::endl;
   // 次元数
   std::cout << "dims:" << src_mat.dims << std::endl;
   // サイズ(2次元の場合)
   std::cout << "size[]:" << src_mat.size().width << "," << src_mat.size().height  << "[byte]" << std::endl;
   // ビット深度ID
   std::cout << "depth (ID):" << src_mat.depth() << "(=" << CV_64F << ")" << std::endl;
   // チャンネル数
   std::cout << "channels:" << src_mat.channels() << std::endl;
   // 1要素内の1チャンネル分のサイズ [バイト単位]
   std::cout << "elemSize1 (elemSize/channels):" << src_mat.elemSize1() << "[byte]" << std::endl;
   // 要素の総数
   std::cout << "total:" << src_mat.total() << std::endl;
   // ステップ数 [バイト単位]
   std::cout << "step:" << src_mat.step << "[byte]" << std::endl;
   // 1ステップ内のチャンネル総数
   std::cout << "step1 (step/elemSize1):" << src_mat.step1()  << std::endl;
   // データは連続か?
   std::cout << "isContinuous:" << (src_mat.isContinuous()?"true":"false") << std::endl;
   // 部分行列か?
   std::cout << "isSubmatrix:" << (src_mat.isSubmatrix()?"true":"false") << std::endl;
   // データは空か?
   std::cout << "empty:" << (src_mat.empty()?"true":"false") << std::endl;
 }
	/// OpenCV2 interface for easy function call
	void filter_xy(const cv::Mat& src,cv::Mat& dst)
	{
		// checking the format of input/output images
		if(src.size()!=dst.size())
			throw std::invalid_argument("\'src\' and \'dst\' should have the same size!");
		if(src.type()!=dst.type())
			throw std::invalid_argument("\'src\' and \'dst\' should have the same element type!");
		if(src.isSubmatrix() || dst.isSubmatrix())
			throw std::invalid_argument("Subimages are unsupported!");

		switch(src.type())
		{
	//	case CV_32FC1: filter_xy< float,1>(src.cols,src.rows,reinterpret_cast< float*>(src.data),reinterpret_cast< float*>(dst.data)); break;
	//	case CV_32FC4: filter_xy< float,4>(src.cols,src.rows,reinterpret_cast< float*>(src.data),reinterpret_cast< float*>(dst.data)); break;
		case CV_64FC1: filter_xy<double,1>(src.cols,src.rows,reinterpret_cast<double*>(src.data),reinterpret_cast<double*>(dst.data)); break;
		case CV_64FC4: filter_xy<double,4>(src.cols,src.rows,reinterpret_cast<double*>(src.data),reinterpret_cast<double*>(dst.data)); break;
		default: throw std::invalid_argument("Unsupported element type or channel!"); break;
		}
	}
Beispiel #3
-20
static inline void ippiGetImage(const cv::Mat &src, ::ipp::IwiImage &dst)
{
    ::ipp::IwiBorderSize inMemBorder;
    if(src.isSubmatrix()) // already have physical border
    {
        cv::Size  origSize;
        cv::Point offset;
        src.locateROI(origSize, offset);

        inMemBorder.left   = (IwSize)offset.x;
        inMemBorder.top    = (IwSize)offset.y;
        inMemBorder.right  = (IwSize)(origSize.width - src.cols - offset.x);
        inMemBorder.bottom = (IwSize)(origSize.height - src.rows - offset.y);
    }

    dst.Init(ippiSize(src.size()), ippiGetDataType(src.depth()), src.channels(), inMemBorder, (void*)src.ptr(), src.step);
}