In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to achieve createTrackbar", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve createTrackbar" this article.
CreateTrackbar is the API in Opencv, which can quickly create a sliding control in the window that displays the image, which can be used to adjust the threshold manually and has a very intuitive effect. The specific definition is as follows:
CV_EXPORTS int createTrackbar (const string& trackbarname, const string& winname, int* value, int count, TrackbarCallback onChange = 0, void* userdata = 0)
Formal parameter 1. Trackbarname: the name of the sliding space
Formal parameter 2. Winname: the name of the image window to which the sliding space is attached.
Formal parameter 3, value: initialization threshold
Formal parameter 4. Count: scale range of sliding controls
Formal parameter 5. TrackbarCallback is a callback function, which is defined as follows:
Typedef void (CV_CDECL * TrackbarCallback) (int pos, void* userdata)
The sample code for its use is as follows:
IplImage * src = NULL, * thresDst = NULL;int threshold_min = 100); cvNamedWindow ("threshold", CV_WINDOW_AUTOSIZE); thresDst = cvCloneImage (src); createTrackbar ("min Threshold", "threshold", & threshold_min, max_lowThreshold, threshold); threshold (0B0)
As you can see, the second parameter of createTrackbar must be exactly the same as the first parameter of cvNameWindow. The callback function is defined and implemented as follows:
Void threshold (int, void*) {cvThreshold (src, thresDst, threshold_min, 255, CV_THRESH_BINARY); cvShowImage ("threshold", thresDst);}
In this way, you can successfully create a sliding control above the image window with the following effect (the original image on the left and a binary image with the sliding control on the right):
The above is all the content of this article "how to achieve createTrackbar". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.