How to decode and show the jpeg stream
井民全, Jing, mqjing@mail.com
#include <opencv2/opencv.hpp> #include <iostream> int main() { // Define the JPEG data as a char array unsigned char jpegData[] = { // Your JPEG data here }; int jpegDataSize = sizeof(jpegData); // Decode the JPEG data using imdecode cv::Mat decodedImage = cv::imdecode(cv::Mat(1, jpegDataSize, CV_8UC1, jpegData), cv::IMREAD_COLOR); // Check if the image was successfully decoded if (decodedImage.empty()) { std::cout << "Failed to decode the image." << std::endl; return -1; } // Display the decoded image cv::imshow("Decoded Image", decodedImage); cv::waitKey(0); return 0; } |