In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces what the enhancement effect of the pictures in Qt5.14 and OpenCV4.5 is like, the content is very detailed, interested friends can refer to, hope to be helpful to you.
1. Establish Qt project 1. Select categories
2. Establish the project name
3. Select the Qt base class and modify the name
4. Select the compiler (choose both here to generate two Debug files)
5. Select the running environment and generate a folder
Generated project folder
6. Copy all the files under the precompiled OpenCV4.5 path F:\ OpenCV4.5.0\ opencv\ buildmingw\ install\ x64\ mingw\ bin to the two folders above Qt.
7. Add the statement INCLUDEPATH + = F:\ OpenCV4.5.0\ opencv\ buildmingw\ install\ includeCONFIG (debug, debug | release) to the project .pro file: {LIBS + = F:\ OpenCV4.5.0\ opencv\ buildmingw\ install\ x64\ mingw\ bin\ libopencv_*d.dll} else:CONFIG (release) Debug | release): {LIBS + =-LF:\ OpenCV4.5.0\ opencv\ buildmingw\ install\ x64\ mingw\ bin\-llibopencv_core450\-llibopencv_highgui450\-llibopencv_imgcodecs450\-llibopencv_imgproc450\-llibopencv_features2d450\-llibopencv_calib3d450}
Complete the project configuration
Interface design 1. Interface and attribute setting
Property settin
Serial number
Name
Types
Property settin
one
ViewLabel
QLabel
FrameShape:Box
FrameShadow:Sunken
two
ContrastVerticalSlider
QSlider
Maximum:100
Value:33
TickPostion:TicksBelow
three
BrightnessVerticalSlider
QSlider
Maximum:100
four
ContrastLabel
QLabel
Text: contrast
five
BrightLabel
QLabel
Text: brightness
2. Declare variables and set public functions in the header file, and generate corresponding definition functions.
3. Complete the function code of each public function / * * interface initialization * * / void PictureEnhance::initMainWindow () {QString imgPath = "D:\\ Qt\\ QtOpencvEnhance\\ lena.jpg" / / Local path (pictures are placed directly under the project directory) Mat imgData = imread (imgPath.toLatin1 (). Data ()); / / read image data cvtColor (imgData,imgData, COLOR_BGR2RGB); / / Image format conversion myImg = QImage ((const unsigned char*) (imgData.data), imgData.cols, imgData.rows, QImage::Format_RGB888) ImgShow ();} / * * process pictures * * / void PictureEnhance::imgProc (float con, int bri) {Mat imgSrc = myImg; Mat imgDst = Mat::zeros (imgSrc.size (), imgSrc.type ()) / / initially generate empty zero-pixel array imgSrc.convertTo (imgDst,-1,con,bri); myQImg = QImage ((const unsigned char*) (imgDst.data), imgDst.cols,imgDst.rows, QImage::Format_RGB888); imgShow () } / * * display picture * * / void PictureEnhance::imgShow () {ui- > ViewLabel- > setPixmap (myQImg.scaled (ui- > ViewLabel- > size (), Qt::KeepAspectRatio)); ui- > ViewLabel- > setScaledContents (true);} 4, slider to achieve function
Go to the uil settings interface, right-click the contrast slider bar, and go to the slot
Complete slot function
/ * contrast slider drag slot * * / void PictureEnhance::on_contrastVerticalSlider_sliderMoved (int position) {imgProc (position / 33.3) } / * contrast slider value change slot * * / void PictureEnhance::on_contrastVerticalSlider_valueChanged (int value) {imgProc (value / 33.3) } / * * Luminance slider drag slot * * / void PictureEnhance::on_brightnessVerticalSlider_sliderMoved (int position) {imgProc (1.0) } / * * Luminance slider value change slot * / void PictureEnhance::on_brightnessVerticalSlider_valueChanged (int value) {imgProc (1.0 focus value);}
Running effect:
About Qt5.14 and OpenCV4.5 in the picture enhancement effect is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.