Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize virtual drag-and-drop effect by using gesture recognition in OpenCV

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces OpenCV how to use gesture recognition to achieve virtual drag and drop effect, the article is very detailed, has a certain reference value, interested friends must read it!

The first step

Set the display box through opencv and call the camera to display the current screen.

Import cv2cap = cv2.VideoCapture (0) cap.set (3Power1280) cap.set (4720) while True: succes, img = cap.read () cv2.imshow ("Image", img) cv2.waitKey (1) step 2

To find the hand in the current screen, this article will use the hand tracking module in cv zone

From cvzone.HandTrackingModule import HandDetectordetector = HandDetector (detectionCon=0.8) # changed the default confidence level to make its detection more accurate

Find the complete code for the hand

Import cv2from cvzone.HandTrackingModule import HandDetectorcap = cv2.VideoCapture (0) cap.set (3Power1280) cap.set (4720) detector = HandDetector (detectionCon=0.8) while True: succes, img = cap.read () detector.findHands (img) lmList, _ = detector.findPosition (img) cv2.imshow ("Image", img) cv2.waitKey (1)

Step three

The third step is to create a square first

Cv2.rectangle (img, (100100), (300300), (0,0,255), cv2.FILLED)

Then check to see if our index finger enters the box, and if so, the box changes color

If lmList: cursor = lmList [8] if 100

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report