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 the camera function of pyqt5 circular label display

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to achieve the pyqt5 circular label display open camera function, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

. In fact, the principle of turning on the camera in label display is similar to that of displaying pictures in label. At most, it is one more timer to update pictures by constantly browsing label.

(the picture below is the ui we designed.)

The default label is square, if you just change the style, you can not achieve the effect of the following figure, the reason is very simple, your ui initialization is round.

But the picture is square, so the last one shows the boxy label (feedback from one of my bloggers after testing)

The final conclusion is that we can only operate on the picture, so that it is already round before it is displayed, how to setpixmap directly to the label.

So the question is, how to make the picture round?

Here we use the knowledge of opencv. There is a mask operation in opencv. We only need to get the image containing the circle through the mask operation. Finally, after adding the fourth transparent channel, our circle image is done, and then we use setpixmap to label to achieve the effect.

Here is the code for some of my masking operations

Opencv = cv2.imread ('. / resource/1231.jpg') # todo specifies the black range minGreen = np.array ([- 1,-1,-1]) maxGreen = np.array ([10,10,10]) # todo determines the black range mask = cv2.inRange (opencv, minGreen) MaxGreen) # todo determine the non-black range self.mask_not = cv2.bitwise_not (mask) # todo lock the white area through bitwise and arithmetic controlled by mask thank you for reading this article carefully I hope the article "how to realize the camera function of pyqt5 circular label display" shared by the editor is helpful to everyone. At the same time, I also hope that you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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