Tag Archives: openCV beginner

Flip Image OpenCV Python

OpenCV provides the flip() function which allows for flipping an image or video frame horizontally, vertically, or both.

 

Reference:

OpenCV documentation:  http://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#flip

Open Multiple Images with OpenCV in Python

Building on our previous example of opening a single image, this guide will explain how to open multiple images. The easiest way to load multiple images is to put all the images into a single folder and loop through the directory opening each one.

This guide doesn’t introduce any new OpenCV functions you shouldn’t already be familiar with from the previous example, but we will include new packages os and os.path to make a list of images to process.

The code

A note on OpenCV image support from the OpenCV docs (http://docs.opencv.org/2.4/doc/tutorials/introduction/display_image/display_image.html)

Note OpenCV offers support for the image formats Windows bitmap (bmp), portable image formats (pbm, pgm, ppm) and Sun raster (sr, ras). With help of plugins (you need to specify to use them if you build yourself the library, nevertheless in the packages we ship present by default) you may also load image formats like JPEG (jpeg, jpg, jpe), JPEG 2000 (jp2 – codenamed in the CMake as Jasper), TIFF files (tiff, tif) and portable network graphics (png). Furthermore, OpenEXR is also a possibility.

Boilerplate code

 

Open an Image with OpenCV in Python

The following code will get you started to load and display an image with OpenCV and Python.

OpenCV functions used:

The code

 

Boilerplate code

 

Where to next?