如何將CV::Mat轉成glm::ma4
阿新 • • 發佈:2018-12-07
void fromCV2GLM(const cv::Mat& cvmat, glm::mat4* glmmat) { if (cvmat.cols != 4 || cvmat.rows != 4 || cvmat.type() != CV_32FC1) { cout << "Matrix conversion error!" << endl; return; } memcpy(glm::value_ptr(*glmmat), cvmat.data, 16 * sizeof(float)); } void fromGLM2CV(const glm::mat4& glmmat, cv::Mat* cvmat) { if (cvmat->cols != 4 || cvmat->rows != 4) { (*cvmat) = cv::Mat(4, 4, CV_32F); } memcpy(cvmat->data, glm::value_ptr(glmmat), 16 * sizeof(float)); }