Edward Lance Lorilla |
- 【GAMEMAKER】Quest (mini map, timer)
- 【PYTHON OPENCV】Tracking any object using dlib discriminative correlation filter tracker
- 【VISUAL VB.NET】Item Box Color
- 【JAVASCRIPT】Click on the pop-up window to pop up the login box
【GAMEMAKER】Quest (mini map, timer) Posted: 20 Apr 2021 08:34 AM PDT Information about object: obj_player Sprite: spr_idle_down Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask: No Physics Object Create Event: execute code: Step Event: execute code: execute code: execute code: Information about object: obj_wall Sprite: spr_wall Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask: No Physics Object Information about object: obj_map Sprite: Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask: No Physics Object Draw GUI Event: execute code: Information about object: obj_chest |
【PYTHON OPENCV】Tracking any object using dlib discriminative correlation filter tracker Posted: 20 Apr 2021 08:17 AM PDT """ Tracking any object using dlib discriminative correlation filter tracker """ # Import required packages:import cv2import dlib def draw_text_info(): """Draw text information""" # We set the position to be used for drawing text and the menu info: menu_pos = (10, 20) menu_pos_2 = (10, 40) menu_pos_3 = (10, 60) info_1 = "Use left click of the mouse to select the object to track" info_2 = "Use '1' to start tracking, '2' to reset tracking and 'q' to exit" # Write text: cv2.putText(frame, info_1, menu_pos, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255)) cv2.putText(frame, info_2, menu_pos_2, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255)) if tracking_state: cv2.putText(frame, "tracking", menu_pos_3, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0)) else: cv2.putText(frame, "not tracking", menu_pos_3, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255)) # Structure to hold the coordinates of the object to track:points = [] # This is the mouse callback function:def mouse_event_handler(event, x, y, flags, param): # references to the global points variable global points # If left button is click, add the top left coordinates of the object to be tracked: if event == cv2.EVENT_LBUTTONDOWN: points = [(x, y)] # If left button is released, add the bottom right coordinates of the object to be tracked: elif event == cv2.EVENT_LBUTTONUP: points.append((x, y)) # Create the video capture to read from the webcam:capture = cv2.VideoCapture(0) # Set window name:window_name = "Object tracking using dlib correlation filter algorithm" # Create the window:cv2.namedWindow(window_name) # We bind mouse events to the created window:cv2.setMouseCallback(window_name, mouse_event_handler) # First step is to initialize the correlation tracker.tracker = dlib.correlation_tracker() # This variable will hold if we are currently tracking the object:tracking_state = Falsewhile True: # Capture frame from webcam: ret, frame = capture.read() # We draw a basic instructions to the user: draw_text_info() # We set and draw the rectangle where the object will be tracked if it has the two points: if len(points) == 2: cv2.rectangle(frame, points[0], points[1], (0, 0, 255), 3) dlib_rectangle = dlib.rectangle(points[0][0], points[0][1], points[1][0], points[1][1]) # If tracking, update tracking and get the position of the tracked object to be drawn: if tracking_state == True: # Update trackingtracker.update(frame) # Get the position of the tracked object: pos = tracker.get_position() # Draw the position: cv2.rectangle(frame, (int(pos.left()), int(pos.top())), (int(pos.right()), int(pos.bottom())), (0, 255, 0), 3) # We capture the keyboard event: key = 0xFF & cv2.waitKey(1) # Press '1' to start tracking using the selected region: if key == ord("1"): if len(points) == 2: # Start tracking: tracker.start_track(frame, dlib_rectangle) tracking_state = True points = [] # Press '2' to stop tracking. This will reset the points: if key == ord("2"): points = [] tracking_state = False # To exit, press 'q': if key == ord('q'): break # Show the resulting image: cv2.imshow(window_name, frame) # Release everything:capture.release()cv2.destroyAllWindows() |
Posted: 20 Apr 2021 08:13 AM PDT Public Class Form1 Public Sub New() MyBase.New() ' This call is required by the designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ListBox1.DrawMode = DrawMode.OwnerDrawFixed End Sub Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged End Sub Private Sub ListBox1_QueryContinueDrag(sender As Object, e As QueryContinueDragEventArgs) Handles ListBox1.QueryContinueDrag End Sub Private Sub ListBox1_DrawItem(sender As Object, e As DrawItemEventArgs) Handles ListBox1.DrawItem e.DrawBackground() Dim g As Graphics = e.Graphics Dim color__1 As Color = Color.Blue For i As Integer = 0 To ListBox1.Items.Count - 1 g.DrawString("ListBoxItem", e.Font, New SolidBrush(color__1), New PointF(e.Bounds.X, e.Bounds.Y)) Next e.DrawFocusRectangle() End SubEnd Class |
【JAVASCRIPT】Click on the pop-up window to pop up the login box Posted: 20 Apr 2021 07:03 AM PDT |
You are subscribed to email updates from Edward Lance Lorilla. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google, 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
No comments:
Post a Comment