Python Forum
Create a list of co-ordinates from Mouse press events
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create a list of co-ordinates from Mouse press events
#1
I'm trying to create a cv2.contour from Mouse press events( i.e., Drawing on the image and converting it into contour)
Here is the code, in this the list is having only 1 x,y coordinate, need to create a list for every Mousepress and convert to cv2.contour.
    def mouseMoveEvent(self, event):
        list = []
        if (event.buttons() & Qt.LeftButton) & self.drawing:
            painter = QPainter(self.image)
            painter.setPen(QPen(self.brushColor, self.brushSize, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
            painter.drawLine(self.lastPoint, event.pos())
            # self.lastPoint = event.pos()
            lastPoint=event.pos()
            self.update()
            print("LASTPOINTS", self.lastPoint)
            self.x = (self.lastPoint.x())
            self.y = (self.lastPoint.y())
            list.append(self.x)
            list.append(self.y)

(Mar-12-2020, 08:46 AM)Jagruthi Wrote: I'm trying to create a cv2.contour from Mouse press events( i.e., Drawing on the image and converting it into contour)
Here is the code, in this the list is having only 1 x,y coordinate, need to create a list for every Mousepress and convert to cv2.contour using PyQt5
    def mouseMoveEvent(self, event):
        list = []
        if (event.buttons() & Qt.LeftButton) & self.drawing:
            painter = QPainter(self.image)
            painter.setPen(QPen(self.brushColor, self.brushSize, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
            painter.drawLine(self.lastPoint, event.pos())
            # self.lastPoint = event.pos()
            lastPoint=event.pos()
            self.update()
            print("LASTPOINTS", self.lastPoint)
            self.x = (self.lastPoint.x())
            self.y = (self.lastPoint.y())
            list.append(self.x)
            list.append(self.y)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Delete strings from a list to create a new only number list Dvdscot 8 1,511 May-01-2023, 09:06 PM
Last Post: deanhystad
  [split] why can't i create a list of numbers (ints) with random.randrange() astral_travel 7 1,505 Oct-23-2022, 11:13 PM
Last Post: Pedroski55
  wait for the first of these events Skaperen 4 1,931 Mar-07-2022, 08:46 PM
Last Post: Gribouillis
  how to easily create a list of already existing item CompleteNewb 15 3,523 Jan-06-2022, 12:48 AM
Last Post: CompleteNewb
  How to open MIDI-file and get events in a list? philipbergwerf 7 4,955 May-29-2021, 08:24 AM
Last Post: j.crater
  Create SQLite columns from a list or tuple? snakes 6 8,657 May-04-2021, 12:06 PM
Last Post: snakes
  Create variable and list dynamically quest_ 12 4,382 Jan-26-2021, 07:14 PM
Last Post: quest_
  How to create a linked list and call it? loves 12 4,479 Nov-22-2020, 03:50 PM
Last Post: loves
  How to create and define in one line a 2D list of class objects in Python T2ioTD 1 2,029 Aug-14-2020, 12:37 PM
Last Post: Yoriz
  How to define a function to create a resorted list? sparkt 6 2,807 Aug-08-2020, 04:10 PM
Last Post: sparkt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020