DLLExport void getCameraTexture(void* camera, unsigned char* data, bool isRecord, bool isShowWin) { auto vc = static_cast<cv::VideoCapture*>(camera); if(isRecord && !videoWriter.isOpened()) { //録画用 videoWriter = cv::VideoWriter("capture.avi", CV_FOURCC('X','V','I','D'), vc->get(CV_CAP_PROP_FPS), cv::Size((int)(vc->get(CV_CAP_PROP_FRAME_WIDTH)), (int)(vc->get(CV_CAP_PROP_FRAME_WIDTH)))); } // カメラ画の取得 cv::Mat img; *vc >> img; if(!img.empty()) { //録画フラグがたっていたら録画もする if(isRecord) videoWriter << img; //std::cout << "img size:" << img.rows << " * " << img.cols << std::endl; if(isShowWin) { // リサイズ cv::Mat resized_img(img.rows * 0.5, img.cols * 0.5, img.type()); cv::resize(img, resized_img, resized_img.size(), cv::INTER_CUBIC); // 別ウィンドウの画を更新 cv::imshow("web camera", resized_img); } //↓↓処理するのはこっちに戻ってやるのだからx反転色変換いらないのでは?? // RGB --> ARGB 変換 // cv::Mat argb_img, flip_img; // //cv::cvtColor(resized_img, argb_img, CV_RGB2BGRA); // cv::cvtColor(img, argb_img, CV_RGB2BGRA); // std::vector<cv::Mat> bgra; // cv::split(argb_img, bgra); // std::swap(bgra[0], bgra[3]); // std::swap(bgra[1], bgra[2]); ////x軸反転 //cv::flip(argb_img, flip_img, 0); // std::memcpy(data, flip_img.data, flip_img.total() * flip_img.elemSize()); std::memcpy(data, img.data, img.total() * img.elemSize()); } }
// After calling CreateCollage() and FastAdjust(), call this function to save result // collage to a image file specified by out_put_image_path. cv::Mat CollageBasic::OutputCollageImage() const { // Traverse tree_leaves_ vector. Resize tile image and paste it on the canvas. assert(canvas_alpha_ != -1); assert(canvas_width_ != -1); cv::Mat canvas(cv::Size(canvas_width_, canvas_height_), image_vec_[0].type()); assert(image_vec_[0].type() == CV_8UC3); for (int i = 0; i < image_num_; ++i) { int img_ind = tree_leaves_[i]->image_index_; FloatRect pos = tree_leaves_[i]->position_; cv::Rect pos_cv(pos.x_, pos.y_, pos.width_, pos.height_); cv::Mat roi(canvas, pos_cv); assert(image_vec_[0].type() == image_vec_[img_ind].type()); cv::Mat resized_img(pos_cv.height, pos_cv.width, image_vec_[i].type()); cv::resize(image_vec_[img_ind], resized_img, resized_img.size()); resized_img.copyTo(roi); } return canvas; }