Posts

Showing posts from August, 2020

Morphological operations using OpenCV

This tutorial will discuss examples of B/W morphological operations using OpenCV.  The code used for this tutorial can be downloaded from here . When you unzip the file from above, you will see the following directory and file structure: bin CMakeLists.txt sample_inputs sample_results src Change to the bin/ folder and compile the code using the commands "cmake ../" and "make". You should see a result as below: acv@acv-vm:~/vision/practice2/bin$ cmake .. -- The C compiler identification is GNU 7.5.0 -- The CXX compiler identification is GNU 7.5.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI i...

Exception handling in C++

Image
Exceptions are used to indicate that a program has encountered run-time anomalies or abnormal conditions. Let us use the Sorter::sortInAscending task that we discussed in an earlier post as an example. To follow this tutorial, it is highly recommended that you download the code from this link and repeat the instructions on your system. The sorting task that we implemented in the earlier post has the following functionality:  Read a text file containing one integer per line. Sort the integers in increasing order. Output the sorted values to another text file. Reading of the text file is implemented in the function Sorter::readIntegersFromFile. Let us run the code using the following command line argument:  ./homework sortint ../sample_data/integers.txt  /tmp/result.txt You will see the sorted list of numbers in the file "/tmp/result.txt". Let us run the code using an input file that does not exist:  ./homework sortint ../sa...

A log Manager for C++

Image
Logging is an important part of any language. Let us assume we are asked to implement the following functionality: Read a text file containing one integer per line. Sort the integers in increasing order. Output the sorted values to another text file. Download the code and sample data as a zip file from this link . Compiling the code using Cmake and make should give you a screen as shown below. When you type the following command: "./homework sortint ../sample_data/integers.txt /tmp/sorted_result.txt", The code should generate a result in the file "/tmp/sorted_result.txt". This file will contain the sorted integers. The console output is shown below: The function declarations are in "Sorter.h". If you go through the "Sorter.h" file, you will notice that the code is well commented. The required functionality is implemented in the function definitions in the file "Sorter.cpp". Let us look at the error and status messa...