cv::Mat vec = (cv::Mat_(1, 5) << 1, 2, 3, 4, 5); int vec_size = vec.checkVector(1); if (vec_size > 0) { std::cout << "The matrix is a vector of size " << vec_size << std::endl; } else { std::cout << "The matrix is not a vector" << std::endl; }
cv::Mat vec = (cv::Mat_These examples demonstrate how to use the checkVector function to determine if a matrix is a vector, and if so, what the size of the vector is. This function is included in the OpenCV package library.(3, 1) << 1, 2, 3); int vec_size = vec.checkVector(1); if (vec_size > 0) { std::cout << "The matrix is a vector of size " << vec_size << std::endl; } else { std::cout << "The matrix is not a vector" << std::endl; }