OpenCV Python Tutorial For Beginners 9 – More Mouse Event Examples in OpenCV Python

///OpenCV Python Tutorial For Beginners 9 – More Mouse Event Examples in OpenCV Python

OpenCV Python Tutorial For Beginners 9 – More Mouse Event Examples in OpenCV Python

FavoriteLoadingAdd to favorites

In the last video I have described How to Handle Mouse Events in OpenCV Python. now In this video on OpenCV Python Tutorial For Beginners, I am going to show some More Mouse Event Examples in OpenCV Python. OpenCV supports for detecting of mouse events. These Mouse events include mouse clicks (like left-button down, left-button up, left-button double-click etc) and movements over an attached OpenCV window. Capturing mouse click events with Python and OpenCV is easy. we just need to create a callback function and call this callback function using cv2.setMouseCallback(‘image’, click_event_callback_function) method

Gist of code I used in this video (How to Detect Mouse Clicks and Moves) –

OpenCV is an image processing library created by Intel and later supported by Willow Garage and now maintained by Itseez. opencv is available on Mac, Windows, Linux. Works in C, C++, and Python.
it is Open Source and free. opencv is easy to use and install.

Starting with an overview of what the course will be covering, we move on to discussing morphological operations and practically learn how they work on images. We will then learn contrast enhancement using equalization and contrast limiting. Finally we will learn 3 methods to subtract the background from the video and implement them using OpenCV.

At the end of this course, you will have a firm grasp of Computer Vision techniques using OpenCV libraries. This course will be your gateway to the world of data science.

Feel the real power of Python and programming! The course offers you a unique approach of learning how to code by solving real world problems.

#ProgrammingKnowledge #ComputerVision #OpenCV
★★★Top Online Courses From ProgrammingKnowledge ★★★
Python Programming Course ➡️ ⚫️
Java Programming Course ➡️ ⚫️
Bash Shell Scripting Course ➡️ ⚫️
Linux Command Line Tutorials ➡️ ⚫️
C Programming Course ➡️ ⚫️
C++ Programming Course ➡️ ⚫️
PHP Programming Course ➡️ ⚫️
Android Development Course ➡️ ⚫️
C# Programming Course ➡️ ⚫️
JavaFx Programming Course ➡️ ⚫️
NodeJs Programming Course ➡️ ⚫️
Jenkins Course For Developers and DevOps ➡️ ⚫️
Scala Programming Tutorial Course ➡️ ⚫️
Bootstrap Responsive Web Design Tutorial ➡️ ⚫️
MongoDB Tutorial Course ➡️ ⚫️
QT C++ GUI Tutorial For Beginners ➡️

★★★ Online Courses to learn ★★★
Get 2 FREE Months of Unlimited Classes from skillshare –
Data Science – |
Machine Learning – |
Artificial Intelligence – |
MERN Stack E-Degree Program – |
DevOps E-degree – |
Data Analytics with R – |
AWS Certification Training – |
Projects in Java – |
Machine Learning With TensorFlow – |
Angular 8 – Complete Essential Guide –
Kotlin Android Development Masterclass –
Learn iOS Programming Building Advance Projects –

★★★ Follow ★★★
My Website –

DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!


By |2020-05-10T03:31:03+00:00May 10th, 2020|Python Video Tutorials|16 Comments


  1. Codehub May 10, 2020 at 3:31 am - Reply

    Hi! It's work fine with lena.jpg but i try to use another picture and got error when i click to pint with strong red
    IndexError: index 313 is out of bounds for axis 1 with size 272
    Someone help me explain this error
    A lot of thanks <3

  2. Aniket Yadav May 10, 2020 at 3:31 am - Reply

    can anyone tell what is flag and param ?

  3. RASHIKA SHAW May 10, 2020 at 3:31 am - Reply

    I want to erase those line drawn in image after sometime….any idea how to do

  4. ichigo sake May 10, 2020 at 3:31 am - Reply

    import cv2
    import numpy as np

    def click_event(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDOWN:
    blue = img[y, x, 0]
    green = img[y, x, 1]
    red = img[y, x, 2], (x, y), 3, (0, 0, 255), -1)
    myColorImage = np.zeros((512, 512, 3), np.uint8)

    myColorImage[:] = [blue, green, red]

    cv2.imshow('color', myColorImage)

    #img = np.zeros((512, 512, 3), np.uint8)
    img = cv2.imread('lena.jpg')
    cv2.imshow('image', img)
    points = []
    cv2.setMouseCallback('image', click_event)


  5. ಠ_ಠ May 10, 2020 at 3:31 am - Reply

    12:50 You have to put the y-coordinate first when getting the channel color, ex "blue = img[y, x, 0]", otherwise you get the diagonally mirrored pixelcolor.

  6. Gayrat Tangriberganov May 10, 2020 at 3:31 am - Reply

    Will you create about OpenCV Tutorial in advanced level?

  7. Tushant Verma May 10, 2020 at 3:31 am - Reply

    "Use cv2.EVENT_LBUTTONUP(in line4)" while running on laptops

  8. GabriellaTM94 May 10, 2020 at 3:31 am - Reply

    very well explained series on OpenCV!

  9. Shashank Sharmadon May 10, 2020 at 3:31 am - Reply

    thanks bro………

  10. Ashhad Ahsan May 10, 2020 at 3:31 am - Reply

    After completing this series please do one on YOLO object detection

  11. Wasit Shafi May 10, 2020 at 3:31 am - Reply

    see line no 6,7, 8 you have mention the coordinates as x,y which is wrong the correct way is to mention them as y, x and the the channel i.e. 0 or 1 or 2….as far as i know about that

  12. himanshu shekhar May 10, 2020 at 3:31 am - Reply

    Color is not matching, because of x and y order, correct format is blue = img[y,x,0] green = img[y,x, 1]
    red = img[y,x,2]

  13. Danuta Rejant May 10, 2020 at 3:31 am - Reply

    That moment of hesitation and concern when you saw colors didnt match 😀 In line 6 to 8 is a mistake should be "blue = img[y,x,0] [..]". If someone could explain me why we have to place "y" in the first place i would be grateful.
    Good job at your videos!

  14. Gradient Soln-En May 10, 2020 at 3:31 am - Reply

    Please Make a Video about how to make an operating system from completely from scratch

  15. 69 Subscribers With No Videos May 10, 2020 at 3:31 am - Reply

    nice vid, just in case it helps some other people, i found that when I was starting, helped a fair bit.

  16. XxMegaBoy May 10, 2020 at 3:31 am - Reply

    Good vid my friend!

Leave A Comment