Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the enhancement effect of pictures in Qt5.14 and OpenCV4.5?

Shulou Source: shulou.com Published: 2022-06-02 09:51:57 09月16日 Update

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.

Tags: Pictures files projects build selection functions contrast interface effects two brightness name properties folders contents functions more paths help compilation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info Xiaomi NVidia Apple