Making Own Image And Image Collage with Python OpenCV library

Govind Bhardwaj
3 min readJun 8, 2021

--

Task Description πŸ“„

πŸ”… Task Step 1

πŸ“Œ Create image by yourself Using Python Code

πŸ”… Task Step 2

πŸ“Œ Take 2 image crop some part of both image and swap it.

πŸ”… Task Step 3

πŸ“Œ Take 2 image and combine it to form single image. For example collage

Introduction to python OpenCV Library-

OpenCV (Open Source Computer Vision Library: http://opencv.org) is an open-source library that includes several hundreds of computer vision algorithms. The document describes the so-called OpenCV 2.x API, which is essentially a C++ API, as opposed to the C-based OpenCV 1.x API (C API is deprecated and not tested with β€œC” compiler since OpenCV 2.4 releases)

OpenCV has a modular structure, which means that the package includes several shared or static libraries. The following modules are available:

  • Core functionality (core) β€” a compact module defining basic data structures, including the dense multi-dimensional array Mat and basic functions used by all other modules.
  • Image Processing (imgproc) β€” an image processing module that includes linear and non-linear image filtering, geometrical image transformations (resize, affine and perspective warping, generic table-based remapping), color space conversion, histograms, and so on.
  • Video Analysis (video) β€” a video analysis module that includes motion estimation, background subtraction, and object tracking algorithms.
  • Camera Calibration and 3D Reconstruction (calib3d) β€” basic multiple-view geometry algorithms, single and stereo camera calibration, object pose estimation, stereo correspondence algorithms, and elements of 3D reconstruction.
  • 2D Features Framework (features2d) β€” salient feature detectors, descriptors, and descriptor matchers.
  • Object Detection (objdetect) β€” detection of objects and instances of the predefined classes (for example, faces, eyes, mugs, people, cars, and so on).
  • High-level GUI (highgui) β€” an easy-to-use interface to simple UI capabilities.
  • Video I/O (videoio) β€” an easy-to-use interface to video capturing and video codecs.

To do these tasks We will use β€œcv2” module

Task Step -1

  • In task step we find by hit and trial some coordinates which are making our required image . Here waitKey() will hold image at infinity time if β€œEnter” key is not pressed

Task Step -2

  • In this task we took two image and after crop some part of images we swap it with python code using numpy operation .

Task Step -3

  • In this task step we will take two image then we will create a collage with these images . We can these images horizontally with numpy.hstack() and vertically with numpy.vstack()
  • Horizontally
  • Vertically

Thank you for giving your time to this article

--

--

No responses yet