Found 33676 Articles for Programming

Using OpenCV in Python to Cartoonize an Image

Arjun Thakur
Updated on 31-Mar-2023 15:38:22

1K+ Views

Currently there are lots of professional cartoonizer applications available in the market but most of the them are not freeware. In order to get the basic cartoon effect, we just need the bilateral filter and some edge dectection mechanism. The bilateral filter will reduce the color palette, which is essential for the cartoon look and edge detection is to produce bold silhouettes.We are going to use openCV python library to convert an RGB color image to a cartoon image.AlgorithmFirstly apply the bilateral filter to reduce the color palette of the image.Then conver the actual image to grayscale.Now apply the median ... Read More

OpenCV Python Program to blur an image?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

612 Views

OpenCV is one of the best python package for image processing. Also like signals carry noise attached to it, images too contain different types of noise mainly from the source itself (Camera sensor). Python OpenCV package provides ways for image smoothing also called blurring. This is what we are going to do in this section. One of the common technique is using Gaussian filter (Gf) for image blurring. With this, any sharp edges in images are smoothed while minimizing too much blurring.Syntaxcv.GaussianBlur(src,  ksize,  sigmaX[,  dst[,  sigmaY[,  borderType=BORDER_DEFAULT]]] )Where−src – input imagedst – output imageksize – Gaussian kernel size[ height width]. If ksize ... Read More

Permutation and Combination in Python?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

1K+ Views

In this section, we are going to learn how to find permutation and combination of a given sequence using python programming language.One of the key advantage of python over other programming language is that it comes with huge set of libraries with it.We are going to use python inbuilt package to find permutation and combinations of a given sequence.Algorithm to find the Permutation and combinationStep 1 : Import required package. First step is to import the required package, as we are going to use itertools package, so we just import it using.>>> import itertools >>>Step 2: Get all permutation & combination ... Read More

How to print Unicode character in C++?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

6K+ Views

To print the Unicode characters, the process is very similar to the actual printing process in C++.We can put the Unicode value with the prefix \u. Thus we can successfully print the Unicode character.Note: If the console does not support Unicode, then you cannot get the correct result. Here we have used the Linux system to solve this problem.Example#include using namespace std; int main() {    cout

Python program to Rearrange a string so that all same characters become d distance away

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

986 Views

Given a non-empty string str and an integer k , rearrange the string such that the same characters are at least distance k from each other.All input strings are given in lowercase letters. If it is not possible to rearrange the string, return an empty string "".Example 1:str = “tutorialspoint”, k = 3 Answer: “tiotiotalnprsu”The same characters are at least 3 character distance apart.str = "aabbcc", k = 3 Answer: "abcabc" The same characters are at least 3 character distance apart.Example 2str = "aaabc", k = 3 Answer: "" It is not possible to rearrange the string.Example 3:str = "aaadbbcc", k = ... Read More

How to make the program sleep for x milliseconds in C++?

Samual Sam
Updated on 30-Jul-2019 22:30:26

527 Views

Here we will see how to sleep for x (given by user) milliseconds in C++ program.To do this thing we can use different libraries. But here we are using the clock() function. The clock() will return the current CPU time. Here we will try to find the ending time from the clock, and the given x value. Then for that amount of time, we will run one blank while loop to take the time. Here one macro is used called CLOCKS_PER_SEC, this finds the number of clock ticks per second.Let us see the code to get the better idea about ... Read More

What is the difference between static_cast<> and C style casting?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

4K+ Views

Here we will see what are the differences between static_cast and normal C style cast.The normal cast like (int)x is C style typecasting where static_cast(x) is used in C++.This static_cast() gives compile time checking facility, but the C style casting does not support that. This static_cast() can be spotted anywhere inside a C++ code. And using this C++ cast the intensions are conveyed much better.In C like cast sometimes we can cast some type pointer to point some other type data.Like one integer pointer can also point character type data, as they are quite similar, only difference is character has ... Read More

Python program to Find the first non-repeating character from a stream of characters?

AmitDiwan
Updated on 11-Aug-2022 11:57:47

9K+ Views

In this article, we will find the first non-repeating character from a stream of character. Let’s say the following is our input − Thisisit The following should be our output displaying first non-repeating character − H Find the first non-repeating character from a stream of characters using while loop We will find the first non-repeating character, by comparing each character with the other using a loop − Example # String myStr = "thisisit" # Looping while myStr != "": slen0 = len(myStr) ch = myStr[0] myStr = myStr.replace(ch, "") slen1 = len(myStr) if slen1 == slen0-1: print ... Read More

How do I generate random floats in C++?

Samual Sam
Updated on 30-Jul-2019 22:30:26

4K+ Views

In C or C++, we cannot create random float directly. We can create random floats using some trick. We will create two random integer values, then divide them to get random float value.Sometimes it may generate an integer quotient, so to reduce the probability of that, we are multiplying the result with some floating point constant like 0.5.Example#include #include #include using namespace std; main() {    srand((unsigned int)time(NULL));    float a = 5.0;    for (int i=0;i

How to automatically generate a stacktrace when a gcc C++ program crashes?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

2K+ Views

For Linux and we can use gcc to compile C/C++ codes. This compiler uses glibc library. We can use the backtrace() function to trace the error. This function is present inside the execinfo.h header file. In this example, we are going to display Segmentation fault error using the stack trace feature.Example#include #include #include #include #include using namespace std; void error_handler(int sig) {    void *array[10];    size_t size;    size = backtrace(array, 10); //get the void pointers for all of the entries    cout

Advertisements