Trending February 2024 # Working Of Bitwise_And() Operator In Opencv # Suggested March 2024 # Top 2 Popular

You are reading the article Working Of Bitwise_And() Operator In Opencv updated in February 2024 on the website Tai-facebook.edu.vn. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 Working Of Bitwise_And() Operator In Opencv

Introduction to OpenCV bitwise_and

Whenever we are dealing with images while solving computer vision problems, there arises a necessity to wither manipulate the given image or extract parts of the given image based on the requirement, in such cases we make use of bitwise operators in OpenCV and when the elements of the arrays corresponding to the given two images must be combined bit wise, then we make use of an operator in OpenCV called but wise and operator using which the arrays corresponding to the two images can be combined resulting in merging of the two images and bit wise operation on the two images returns an image with the merging done as per the specification.

Start Your Free Software Development Course

The syntax to define bitwise_and() operator in OpenCV is as follows:

bitwise_and(source1_array, source2_array, destination_array, mask)

where source1_array is the array corresponding to the first input image on which bitwise and operation is to be performed,

source2_array is the array corresponding to the second input image on which bitwise and operation is to be performed,

destination_array is the resulting array by performing bitwise operation on the array corresponding to the first input image and the array corresponding to the second input image and

mask is the mask operation to be performed on the resulting image and it is optional.

Working of bitwise_and() Operator in OpenCV

Working of bitwise_and() operator in OpenCV is as follows:

In order to be able to perform bit wise conjunction of the two arrays corresponding to the two images in OpenCV, we make use of bitwise_and operator.

To be able to make use of bitwise_and operator in our program, we must import the module cv2.

The images whose arrays are to be combined using bitwise_and operator are read using imread() function.

Then the corresponding arrays of those images are passed to the bitwise_and operator.

The bitwise_and operator returns an array that corresponds to the resulting image from the merger of the given two images.

The operation of bitwise_and can be done on images having same dimensions only.

Examples of OpenCV bitwise_and

Following are the examples are given below:

Example #1

OpenCV program in python to demonstrate bitwise_and operator to read two images using imread() function and then merge the given two images using bitwise_and operator and then display the resulting image as the output on the screen:

Code:

#importing the modules cv2 and numpy import cv2 import numpy as np #reading the two images that are to be merged using imread() function imageread1 = cv2.imread('C:/Users/admin/Desktop/plane.jpg') imageread2 = cv2.imread('C:/Users/admin/Desktop/car.jpg') #using bitwise_and operation on the given two images resultimage = cv2.bitwise_and(imageread1, imageread2, mask = None) #displaying the merged image as the output on the screen cv2.imshow('Merged_image', resultimage) cv2.waitKey(0) cv2.destroyAllWindows()

Output:

In the above program, we are importing the module cv2 and numpy. Then we are reading the two images that are to be merged using imread() function. Then we making use of bitwise_and operator by specifying the two input images as the parameters which returns the merged image as the resulting image displayed as the output on the screen. The output is shown in the snapshot above.

Example #2

OpenCV program in python to demonstrate bitwise_and operator to read two images using imread() function and then merge the given two images using bitwise_and operator and then display the resulting image as the output on the screen:

#importing the modules cv2 and numpy import cv2 import numpy as np #reading the two images that are to be merged using imread() function imageread1 = cv2.imread('C:/Users/admin/Desktop/logo.png') imageread2 = cv2.imread('C:/Users/admin/Desktop/educbalogo.jpg') #using bitwise_and operation on the given two images resultimage = cv2.bitwise_and(imageread1, imageread2, mask = None) #displaying the merged image as the output on the screen cv2.imshow('Merged_image', resultimage) cv2.waitKey(0) cv2.destroyAllWindows()

Output:

In the above program, we are importing the module cv2 and numpy. Then we are reading the two images that are to be merged using imread() function. Then we making use of bitwise_and operator by specifying the two input images as the parameters which returns the merged image as the resulting image displayed as the output on the screen. The output is shown in the snapshot above.

Example #3

OpenCV program in python to demonstrate bitwise_and operator to read two images using imread() function and then merge the given two images using bitwise_and operator and then display the resulting image as the output on the screen:

 Code:

#importing the modules cv2 and numpy import cv2 import numpy as np #reading the two images that are to be merged using imread() function imageread1 = cv2.imread('C:/Users/admin/Desktop/tree.jpg') imageread2 = cv2.imread('C:/Users/admin/Desktop/educbatree.jpg') #using bitwise_and operation on the given two images resultimage = cv2.bitwise_and(imageread1, imageread2, mask = None) #displaying the merged image as the output on the screen cv2.imshow('Merged_image', resultimage) cv2.waitKey(0) cv2.destroyAllWindows()

Output:

In the above program, we are importing the module cv2 and numpy. Then we are reading the two images that are to be merged using imread() function. Then we making use of bitwise_and operator by specifying the two input images as the parameters which returns the merged image as the resulting image displayed as the output on the screen. The output is shown in the snapshot above.

Example #4

OpenCV program in python to demonstrate bitwise_and operator to read two images using imread() function and then merge the given two images using bitwise_and operator and then display the resulting image as the output on the screen:

 Code:

#importing the modules cv2 and numpy import cv2 import numpy as np #reading the two images that are to be merged using imread() function imageread1 = cv2.imread('C:/Users/admin/Desktop/plane1.jpg') imageread2 = cv2.imread('C:/Users/admin/Desktop/educbatree.jpg') #using bitwise_and operation on the given two images resultimage = cv2.bitwise_and(imageread1, imageread2, mask = None) #displaying the merged image as the output on the screen cv2.imshow('Merged_image', resultimage) cv2.waitKey(0) cv2.destroyAllWindows()

Output:

In the above program, we are importing the module cv2 and numpy. Then we are reading the two images that are to be merged using imread() function. Then we making use of the bitwise_and operator by specifying the two input images as the parameters which returns the merged image as the resulting image displayed as the output on the screen. The output is shown in the snapshot above.

Recommended Articles

We hope that this EDUCBA information on “OpenCV bitwise_and” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

You're reading Working Of Bitwise_And() Operator In Opencv

Working Of Substr() Function In C++

Introduction to C++ Substring

In C++, a substring refers to a part of a string. To retrieve a substring from a given string in C++, the substr() function is used. It takes the two parameters position and length, where position represents the starting position of the substring in the given string, and length represents the number of characters in the substring to be retrieved from the given string. This substr() function returns the substring extracted from the given string starting from the specified position up to the number of characters from the starting position specified as length.

Start Your Free Software Development Course

Syntax:

substr(position, length)

Where “position” represents the starting position of the substring in the given string, and “length” represents the number of characters in the substring to retrieve from the given string.

Working of Substr() Function in C++

Working of substr() function in C++ is as follows:

In C++, we use the substr() function to retrieve a substring from a given string. A substring in C++ refers to a part of the string.

The substr() function takes two parameters: position and length.

The parameter position represents the starting position of the substring in the given string.

The parameter length represents the number of characters in the substring to retrieve from the given string.

The substr() function returns the substring extracted from the given string starting from the specified position up to the number of characters from the starting position specified as length.

Examples of C++ Substring

Following are the examples:

Example #1

C++ program to demonstrate substr function that returns the substring extracted from the given string starting from the specified position up to the number of characters from the starting position specified as length:

Code:

using namespace std; int main() { string strone = "Welcome to C++_learning"; string strtwo = strone.substr(11, 12); cout << "The given string is: " << strone << "n" <<endl; cout << "The substring extracted from the given string is: " << strtwo << "n" << endl; return 0; }

Output:

In the above program, we have included the headers iostream and string, allowing us to use cin, court, and substr. The program executes the primary method and defines a string variable, “strone,” to store the original string from which a substring will be extracted. Using the substr function, the program extracts a substring from the string “strone,” starting from a specified position and extending for a specified length. The resulting substring is stored in the string variable “strtwo.” Finally, the program displays the extracted substring, which is stored in the variable “strtwo,” as the output on the screen.

Example #2

C++ program to demonstrate substr function that returns the substring extracted from the given string starting from the specified position up to the number of characters from the starting position specified as length:

Code:

using namespace std; int main() { string strone = " EDUCBA is the best site for learning"; string strtwo = strone.substr(0, 6); cout << "The given string is: " << strone << "n" <<endl; cout << "The substring extracted from the given string is: " << strtwo << "n" << endl; return 0; }

Output:

Example #3

C++ program to demonstrate substr function that returns the substring extracted from the given string starting from the specified position up to the number of characters from the starting position specified as length:

Code:

using namespace std; int main() { string strone = " Learning is fun"; string strtwo = strone.substr(12, 3); cout << "The given string is: " << strone << "n" <<endl; cout << "The substring extracted from the given string is: " << strtwo << "n" << endl; return 0; }

Output:

In the above program, we have included the headers iostream and string, allowing us to use cin, court, and substr. The program calls the main method and defines a string variable called “strone” to store the original string. The program then uses the substr function to extract a substring from the string “strone” starting from a specified position and extending for a specified length. It stores the resulting substring in the string variable “strtwo.” Finally, the program displays the extracted substring, which is stored in the variable “strtwo,” as the output on the screen.

Recommended Articles

We hope that this EDUCBA information on “C++ Substring” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Charges Dropped Against Spam Blacklist Operator

Belatedly convinced he’s not just another hacker, Battle Creek, Mich., officials are withdrawing an injunction and dropping charges against ORBZ blacklist owner Ian Gulliver, city officials announced Thursday evening.

The news comes roughly 30 hours after he shut down the controversial service to avoid handing documents over to the Michigan district court, sparking widespread outrage from anti-spam organizations and Internet service providers (ISPs) alike.

Michelle Reen, the city’s assistant to the city manager, issued a quasi-apology to those affected by the shutdown, mainly ISPs whose servers were nearly swamped as the machines tried to keep up with the influx of spam.

Read Related Story

Blacklist’s Demise Rekindles Spam Filtering Debate

In the statement, she said the city’s police force takes potential hacking abuses seriously.

“Our investigation and conversations with Mr. Gulliver’s attorney have led us to believe that there was no criminal intent to cause the City harm,” she said. “However, there was no way for us to know when we received the hit that this was not intended as a malicious prank.”

Battle Creek’s information systems expert and a local detective were responsible for convincing a judge to issue a search warrant and seek to seize Gulliver’s ORBZ documentation.

“The detective had no reason not to believe he was pursuing a hacker when he issued a search warrant,” Reen said. “The purpose of the search warrant was to determine the identity of the person who sent the email that caused our system to fail so we could then determine whether further investigation would be necessary.”

Rather than having the only blacklist files in the hand’s of local government, Gulliver disseminated them to several foreign individuals who would presumably continue in the tradition of the blacklist project started with ORBS years ago, according to one source familiar with situation.

It might be a case of too little, too late for users of the incredibly effective ORBZ blacklist, which blocks IP addresses of know servers with open relays — a frequent target of spammers and unscrupulous unsolicited commercial e-mail (UCE) mass-marketers.

Forbes Mercy, owner of chúng tôi an ISP in Yakima, Wash., was one of many people around the U.S. who fired off an angry letter to city officials for shutting down a service that kept spam, porn and e-mail viruses off computers.

The fact the courts are dropping charges means nothing, he said in his e-mail addressed to the city’s mayor, attorney general and IT specialist, if it means ORBZ doesn’t come back online.

“As a city manager you can now say “I upheld the rights of citizens to be excessively spammed and receive pornography,” he added.

E-mail discussion list forums (ironically enough, forums that have been mistaken for spammers in the past themselves and blacklisted) had little good to say about the city’s handling of the ORBZ situation.

“How hard is it to call the guy and question him before forcing him to shut down?” one member queried. “It could’ve been blown over with a 20 minute phone call, now it’s probably too late (for ORBZ).”

Working And Examples Of Typescript Enum

Introduction to TypeScript enum

The new data type supported in TypeScript is called enumerations or enum using which lets us declare names which means a collection of related values which can be either string or numeric, and there are three types of enums in TypeScript, namely Numeric enum, string enum and Heterogeneous enum where numeric enum are the enums based on numbers that are they store numbers in the form of the string, string enum is the enums based on strings that is they store string values, heterogeneous enum are the enums based on both strings and numbers that is they store both string and numeric values.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

enum enum_name{ enum_value1, enum_value2, .. Enum_valuen }

where enum_name represents the name of the enum,

enum_value1, enum_value2, and enum_valuen represent the collection of related values, either string or numeric.

Working of enum in TypeScript

The new data type supported in TypeScript is called enumerations or enum using which lets us declare names which means a collection of related values that can be either string or numeric.

The keyword enum is used to define enum in TypeScript.

There are three types of enum in TypeScript, namely Numeric enum, string enum, and Heterogeneous enum.

Numeric enum is the enums based on numbers; they store numbers in the form of strings.

The enum values for numeric enum begin from zero and increase by one for each number.

There is also an option to initialize the first enum value ourselves in a numeric enum, and the rest of the values would be increased by one.

The enum values do not have to be in sequence in the numeric enum.

String enum is the enums based on strings that is they store string values.

The readability of the program increases by using a string enum.

Heterogeneous enum is the enums based on both strings and numbers; they store both string and numeric values.

Examples of TypeScript enum

Different examples are mentioned below:

Example #1

TypeScript program to demonstrate the usage of numeric enum that initializes values and are displayed as the output on the screen:

Code:

enum Country { India, USA, Germany, London } console.log("The values initialized by enum is as follows:"); console.log(Country.India); console.log(Country.USA); console.log(Country.Germany); console.log(Country.London);

Output:

In the above program, by using the keyword enum, we define a numeric enum whose values are initialized starting from zero and incremented by one for each member. Then the initialized values for the numeric enum are displayed as the output on the screen.

Example #2

TypeScript program to demonstrate the usage of numeric enum that initializes values where the first value is initialized by ourselves and are displayed as the output on the screen:

Code:

enum Country { India = 5, USA, Germany, London } console.log("The values initialized by enum is as follows:"); console.log(Country.India); console.log(Country.USA); console.log(Country.Germany); console.log(Country.London);

Output:

In the above program, by making use of the keyword enum, we are defining a numeric enum in which the first value is initialized as five by ourselves and then incremented by one for each member. Then the initialized values for the numeric enum are displayed as the output on the screen.

Example #3

TypeScript program to demonstrate the usage of string enum that initializes string values and are displayed as the output on the screen:

Code:

enum Capital { India = 'New Delhi', USA = 'Washington', Germany = 'Berlin', England = 'London' } console.log("The values initialized by string enum is as follows:"); console.log(Capital.India); console.log(Capital.USA); console.log(Capital.Germany); console.log(Capital.England);

Output:

In the above program, by using the keyword enum, we define a string enum whose values are initialized to certain string values. Then the initialized values for the string enum is displayed as the output on the screen.

Example #4

TypeScript program to demonstrate the usage of heterogeneous enum that initializes both string values and numeric values and are displayed as the output on the screen:

Code:

enum Capital { India = 1, USA = 'Washington', Germany = 3, England = 'London' } console.log("The values initialized by heterogeneous enum is as follows:"); console.log(Capital.India); console.log(Capital.USA); console.log(Capital.Germany); console.log(Capital.England);

In the above program, by using the keyword enum, we define a heterogeneous enum whose values are initialized to certain string values and certain numeric values. Then the initialized values for the heterogeneous enum is displayed as the output on the screen.

Example #5

TypeScript program to demonstrate the usage of heterogeneous enum that initializes both string values and numeric values and are displayed as the output on the screen:

Code:

enum Capital { India = 8, USA = 12, Germany = 'Berlin', England = 'London' } console.log("The values initialized by heterogeneous enum is as follows:"); console.log(Capital.India); console.log(Capital.USA); console.log(Capital.Germany); console.log(Capital.England);

Output:

In the above program, by using the keyword enum, we define a heterogeneous enum whose values are initialized to certain string values and certain numeric values. Then the initialized values for the heterogeneous enum is displayed as the output on the screen.

Recommended Articles

We hope that this EDUCBA information on “TypeScript enum” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Guide To The Working Of Postgresql Replication

Introduction to PostgreSQL Replication

It is necessary to implement various strategies to maintain the high availability of the PostgreSQL database and achieve load balancing in scenarios with a large number of users. One such strategy is utilizing multiple database servers collaborating to serve the users effectively. In this case, it is very easy to provide this facility if all the operations are read-only, which means no operation is performed on the data present in the database servers; only the available data is retrieved. In this topic, we are going to learn about PostgreSQL Replication.

Start Your Free Data Science Course

But in the case of reading/write, servers that involve all kinds of manipulations on the database’s data becomes difficult. This is because a single change in one database should be reflected in all the database servers that are serving the users. In this scenario, data replication is utilized to duplicate or replicate data across multiple database servers. It involves making the same change in all the database servers with which the server is operating, ensuring high availability for the end-users.

Working on PostgreSQL Replication

In PostgreSQL, typically, there is one database server that handles all modification-related operations and requests. Other database servers, commonly referred to as slave servers or standby database servers, then replicate or propagate these changes. That means the master nodes are always the replicated data’s senders, while slave nodes receive the replicated data and apply the same changes over there.

PostgreSQL provides a built-in replication feature known as streaming replication, which operates on a master-slave architecture. When utilizing cascading, both the slave or standby database servers have the capability to send and receive replicated data to and from the master database server.

The slave of standby servers always keep track of the changes made by the master server and tries to keep themselves updated. There are two types of standby database servers, namely hot and warm standby servers. Warm servers are servers that require promotion to the master server role before they can accept user connections. On the other hand, hot standby servers are capable of accepting user connections and performing read-only operations.

The streaming replication system in PostgreSQL utilizes the Write-Ahead Log (WAL) file logging system. This system marks a transaction as committed before applying the corresponding change to the target database. However, this difference is minimal; hence there is no inconsistency between the main and replicated database values.

Settings

In the upcoming sections of this article, we will discuss the settings that need to be configured on each of the master, slave, or sending users.

Sending database servers 1. max_wal_senders(integer)

The maximum number of allowed connections with other slave database servers at a single instance can be specified by this parameter. The parameter’s default value is zero, indicating the absence of replication support and disallowing replicated database connections. This value cannot exceed max_connections as this value is equivalent to the number of current wal connections.

2. wal_keep_segments(integer)

The standby servers require 16-megabytes of past log files stored in the pg_xlog directory for streaming replication in Postgres. The minimum number of segments required by the standby servers for proper replication can be specified by this parameter. You can set its value either from the server command line prompt or the chúng tôi configuration file of PostgreSQL.

3. replication_timeout(integer)

If the standby servers crash or if some network issues occur, the connection to that server must terminate. The server command line prompt or the chúng tôi configuration file of PostgreSQL is where you can modify this parameter. The connection will be terminated if no response is received within a specified time span. The default value for this parameter is 60 seconds.

Master database servers

You should configure the mentioned parameters on the server that serves as the master node or primary node. Additionally, you can also set these parameters on standby servers that may be promoted to the master role in the future.

1. synchronous_standby_names( string )

During replication, there are two modes available: synchronous and asynchronous. In synchronous replication, all participating servers in the replication process must confirm the data modification before it is considered committed. This ensures data consistency across all database servers. On the other hand, asynchronous replication may introduce a slight time difference between the transaction’s commitment and the actual changes being made in the target databases. This can occasionally result in stale results. The “synchronous_standby_names” parameter stores a comma-separated list of standby database servers that support synchronous replication.

2. vacuum_defer_cleanup_age( integer ) Slave/Standby database servers

You should configure the mentioned settings on the slave or standby database servers intended to receive the replicated data.

1. hot_standby(boolean)

The default value of this parameter is set to false. It determines whether it is permissible to establish connections and execute queries while data recovery is in progress.

2. max_standby_archive_delay( integer )

The default value for this parameter is 30 seconds. In the context of hot standby servers, PostgreSQL’s streaming replication feature specifies a duration to wait before canceling queries from standby servers. The wait time is crucial for preventing potential conflicts with upcoming Write-Ahead Log (WAL) entries that are about to be applied.

In addition to the above, three more settings must be configured on the slave server: max_standby_streaming_delay, wal_receiver_status_interval, and hot_standby_feedback.

Conclusion- PostgreSQL Replication

We can provide high-availability and balance the load on the database server by maintaining multiple database servers that can work together and implement replication to serve a large number of users without affecting the performance much in the PostgreSQL database. When performing replication, it is crucial to exercise caution and ensure that all settings are properly configured for the respective database servers based on the role they will fulfill in replication and request handling.

Recommended Articles

We hope that this EDUCBA information on “PostgreSQL Replication” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Mtp Not Working In Windows 10

Getting the similar pop-up error message window? Can’t transfer files from your multimedia device to your Computer? You are not alone; many Windows 10 users are on the same page. Media Transfer Protocol (MTP) is mandatory to have when you are transferring files from your phone to the system.

The problem starts when MTP stops working and leaves you with the “MTP USB Device Failed” error message. However, you don’t need to worry as our experts’ have a handful of real-time fixes for this issue. Go through and resolve MTP not working in Windows 10 within a few minutes!

MTP USB device not installing

MTP not recognized

MTP USB Device driver failed

Whenever you get one of these error messages, try performing the below troubleshooting steps. Once you try all of our solutions, you are bound to get it resolved. Here you go!

Fixing MTP driver for Windows 10 error is not a walk in the park. You need to have sound knowledge to do it on your own. Since everyone is not a tech wiz, we have tried to make it easy for you. Take a glance at our basic yet effective solutions and get rid of the error message.

Before you jump to troubleshooting steps, you must check your phone’s compatibility with MTP beforehand. A number of the older version of android phones don’t support MTP. If that is the case, you can’t transfer your media files to the PC. You have to change your phone to resolve the error.

Luckily, most of the Android, Windows mobile, and iOS provide MTP supported smartphones. Hence, if you are using a newer version of Android mobile, there must not exist a compatibility issue. So check for the rest of our solutions to discard the Android MTP driver problem.

Whenever you connect your phone or multimedia device with the system, it installs all the necessary drivers automatically. Sometimes, your PC may lack installing proper Media Transfer Protocol drivers or updating the drivers. Hence, you need to update it manually. Here is how to do that.

Press the Windows logo key + X button at the same time to open menu

Next select “Device Manager” from the appearing list

Once it opens, navigate to the “View” menu and check the box beside “Show hidden devices” option

After that, find your connected device(phone, camera or tablet) in the Device Manager

Now, select “Update Driver Software” from the appearing menu

Then, you should find your device under the “Portable devices” or the “Other devices” section

Next, you have to choose “Search automatically for updated driver software”

Give it a few minutes now to let Windows 10 search for the latest version of the driver and install it.

If you think your PC doesn’t have necessary drivers, then install it manually by following the steps below.

Open “Device Manager” and navigate to “Update Driver Software” by following the similar steps, given above

Now a new window will open, hit the “Browse my computer for driver software” option there

If you don’t want to perform this process, visit your manufacturer’s website and download the latest compatible USB driver according to your multimedia device.

Once you complete the whole process, try to check if the issue is still there. If it is, follow our next troubleshooting steps to fix your MTP USB device driver Windows 10.

If both of these above methods fail, try to fix the Android MTP driver issue using Command Prompt. Follow the steps below to do so.

At first, hold the Windows logo key + X button at a time

Next, a menu will appear, select “Command Prompt (Admin)” from there

Now, you have to type “net localgroup Administrators local service /add” in the command prompt window and hit enter

Once you entirely run the command, close the window and check for the issue again. In case this solution can’t help you, perform the next one.

When your registry key is at fault, none of the above fixes will help you out. You have to repair the registry key settings to fix your problem. Here is the method, have a look.

Now you have to follow the path- “HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControl/Class“

Next, press the Ctrl key + F button together to open the find window

Then you should search for “Portable Devices” and hit the enter button

When the next window opens, you will get Portable Devices and the (Default) value on the same string

Finally, exit the Registry Editor and Reboot your PC

At last if everything fails, you can check out this post where we shave mentioned other methods to transfer files from mobile to PC and vice versa.

Adieu, folks!

Update the detailed information about Working Of Bitwise_And() Operator In Opencv on the Tai-facebook.edu.vn website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!