Search
 
SCRIPT & CODE EXAMPLE
 

CPP

merge images opencv c++

#include <opencv2opencv.hpp>
using namespace cv;

int main()
{
    // Load images
    Mat3b img1 = imread("path_to_image_1");
    Mat3b img2 = imread("path_to_image_2");

    // Get dimension of final image
    int rows = max(img1.rows, img2.rows);
    int cols = img1.cols + img2.cols;

    // Create a black image
    Mat3b res(rows, cols, Vec3b(0,0,0));

    // Copy images in correct position
    img1.copyTo(res(Rect(0, 0, img1.cols, img1.rows)));
    img2.copyTo(res(Rect(img1.cols, 0, img2.cols, img2.rows)));

    // Show result
    imshow("Img 1", img1);
    imshow("Img 2", img2);
    imshow("Result", res);
    waitKey();

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: eosio multi index clear 
Cpp :: swap using Function template in c++ 
Cpp :: have unique vector after sorting vector 
Cpp :: angle to vector2 
Cpp :: inserting at start in vector c++ 
Cpp :: grpah class data structure 
Cpp :: Name one example of a “decider” program that you regularly encounter in real life. 
Cpp :: convert set to vector c++ 
Cpp :: ue4 bind function to button clicked c++ 
Cpp :: watermelon codeforces solution 
Cpp :: vs code text in line 
Cpp :: how to know if two vertexes are connected in graph c++ 
Cpp :: average of a matrix c++ 
Cpp :: c++ cmd program run in background 
Cpp :: extern shared memory 
Cpp :: eosio name to string 
Cpp :: if not defined c++ 
Cpp :: read string from binary file in c++ 
Cpp :: create n threads cpp 
Cpp :: c++ loop pyramid 
Cpp :: sum of stack c++ 
Cpp :: insertion sort c++ 
Cpp :: how to make a c++ program which takes two integers and calculate average 
Cpp :: what is the difference between i++ and ++ i ? 
Cpp :: how to traverse a linked list in c++ 
Cpp :: c++ extend class 
Cpp :: max function in c++ 
Cpp :: set precision with fixed c++ 
Cpp :: iteraate through a vector 
Cpp :: convert binary string to int c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =