Last active
August 29, 2015 14:21
-
-
Save Noxalus/a36e52f62cb45585cdf7 to your computer and use it in GitHub Desktop.
OpenCV draw a simple circle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void proccessImage(std::vector<unsigned char>& imageData, int width, int height) | |
{ | |
// Create cv::Mat from std::vector<unsigned char> | |
Mat src(width, height, CV_8UC4, const_cast<unsigned char*>(imageData.data())); | |
Mat final; | |
// Draw a circle at position (300, 200) with a radius of 30 | |
cv::Point center(300, 200); | |
circle(src, center, 30.f, CV_RGB(0, 0, 255), 3, 8, 0); | |
// Convert the gray image to RGBA | |
cvtColor(src, final, CV_BGRA2RGBA); | |
// Reform the std::vector from cv::Mat data | |
std::vector<unsigned char> array; | |
array.assign((unsigned char*)final.datastart, (unsigned char*)final.dataend); | |
// Send final image data to GPU and draw it | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment