Skip to content

Instantly share code, notes, and snippets.

@ryochack
Created February 25, 2019 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryochack/b0366dc6418042f57d742edcc57798ea to your computer and use it in GitHub Desktop.
Save ryochack/b0366dc6418042f57d742edcc57798ea to your computer and use it in GitHub Desktop.
#include <memory>
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
int main() {
std::unique_ptr<uint8_t[]> bufl(new uint8_t[320 * 240]);
memset(bufl.get(), 0x00, 320*240/2*sizeof(uint8_t));
memset(bufl.get()+320*240/2, 0x44, 320*240/2*sizeof(uint8_t));
cv::Mat imgl = cv::Mat(cv::Size(160, 240), CV_8UC1, bufl.get(), 320);
cv::imshow("left", imgl);
std::unique_ptr<uint8_t[]> bufr(new uint8_t[320 * 240]);
memset(bufr.get(), 0x88, 320*240/2*sizeof(uint8_t));
memset(bufr.get()+320*240/2, 0xcc, 320*240/2*sizeof(uint8_t));
cv::Mat imgr = cv::Mat(cv::Size(160, 240), CV_8UC1, bufr.get(), 320);
cv::imshow("right", imgr);
std::vector<cv::Mat> imgs = { imgl, imgr };
cv::Mat concated;
cv::hconcat(imgs, concated);
cv::imshow("concat", concated);
while (cv::waitKey(0) != 'q');
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment