From 13f41a419713376d6f98040b211da130600eba3f Mon Sep 17 00:00:00 2001 From: xiaoming <2014500726@smail.xtu.edu.cn> Date: Fri, 10 Feb 2023 14:51:14 +0800 Subject: [PATCH] src:add png file import Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn> --- .github/workflows/windows.yml | 1 + YUVviewer.pro | 2 ++ build_dmg.sh | 1 + build_setup.bat | 1 + src/UI_YUVviewer.ui | 5 +++++ src/YUVdecoder.cpp | 16 ++++++++++++++++ src/YUVdecoder.h | 1 + src/YUVviewer.cpp | 5 +++-- test/640x480.png | Bin 0 -> 323850 bytes 9 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/640x480.png diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 8ab062c..093aa9e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -67,6 +67,7 @@ jobs: ./tools/sed/sed.exe -i "s/QT_TOOLS_DIR=C:\/Qt\/Qt6.2.0\/Tools\/mingw810_32\/bin/QT_TOOLS_DIR=C:\/ProgramData\/Chocolatey\/lib\/mingw\/tools\/install\/mingw64\/bin/g" ./build_setup.bat ./tools/sed/sed.exe -i "s/OPENCV_DIR=D:\/Qt\/opencv4.2.0\/x64\/mingw\/bin/OPENCV_DIR=C:\/opencv4.0.0\/x64\/mingw\/bin/g" ./build_setup.bat ./tools/sed/sed.exe -i "s/libopencv_imgproc420/libopencv_imgproc400/g" ./build_setup.bat + ./tools/sed/sed.exe -i "s/libopencv_imgcodecs420/libopencv_imgcodecs400/g" ./build_setup.bat ./tools/sed/sed.exe -i "s/libopencv_core420/libopencv_core400/g" ./build_setup.bat ./tools/sed/sed.exe -i "s/OPENCV_DIR=D:\\Qt\\opencv4.2.0/OPENCV_DIR=C:\\opencv4.0.0/g" ./partform_win32.pri ./build_setup.bat diff --git a/YUVviewer.pro b/YUVviewer.pro index 500010f..6894642 100644 --- a/YUVviewer.pro +++ b/YUVviewer.pro @@ -93,6 +93,7 @@ unix:!macx:{ DEPENDPATH +=$${OPENCV_DIR}/include LIBS += -L $${OPENCV_DIR}/lib/ -lopencv_imgproc + LIBS += -L $${OPENCV_DIR}/lib/ -lopencv_imgcodecs LIBS += -L $${OPENCV_DIR}/lib/ -lopencv_core git_tag.commands = $$quote("cd $$PWD && git describe --always --long --dirty --abbrev=10 --tags | awk \'{print \"\\\"\"\$$0\"\\\"\"}\' > git_tag.inc") @@ -109,6 +110,7 @@ macx:{ DEPENDPATH +=$${OPENCV_DIR}/include LIBS += -L $${OPENCV_DIR}/lib/ -lopencv_imgproc + LIBS += -L $${OPENCV_DIR}/lib/ -lopencv_imgcodecs LIBS += -L $${OPENCV_DIR}/lib/ -lopencv_core git_tag.commands = $$quote("cd $$PWD && git describe --always --long --dirty --abbrev=10 --tags | awk \'{print \"\\\"\"\$$0\"\\\"\"}\' > git_tag.inc") diff --git a/build_dmg.sh b/build_dmg.sh index 976d4a3..7f86a58 100755 --- a/build_dmg.sh +++ b/build_dmg.sh @@ -31,6 +31,7 @@ cd ./build_release/out # 打包 macdeployqt YUVviewer.app cp $OPENCV_DIR/lib/libopencv_imgproc.4.0.dylib ./YUVviewer.app/Contents/Frameworks/libopencv_imgproc.4.0.dylib +cp $OPENCV_DIR/lib/libopencv_imgcodecs.4.0.dylib ./YUVviewer.app/Contents/Frameworks/libopencv_imgcodecs.4.0.dylib cp $OPENCV_DIR/lib/libopencv_core.4.0.dylib ./YUVviewer.app/Contents/Frameworks/libopencv_core.4.0.dylib otool -L ./YUVviewer.app/Contents/MacOS/YUVviewer ./build-dmg.sh YUVviewer diff --git a/build_setup.bat b/build_setup.bat index db7a2c1..c8f715a 100644 --- a/build_setup.bat +++ b/build_setup.bat @@ -41,6 +41,7 @@ xcopy /y .\test\* .\InnoSetup\build\test\ :: 使用windeployqt拷贝依赖dll库到打包目录 windeployqt --dir .\InnoSetup\build .\InnoSetup\build\YUVviewer.exe xcopy /y "%OPENCV_DIR%\libopencv_imgproc420.dll" ".\InnoSetup\build\" +xcopy /y "%OPENCV_DIR%\libopencv_imgcodecs420.dll" ".\InnoSetup\build\" xcopy /y "%OPENCV_DIR%\libopencv_core420.dll" ".\InnoSetup\build\" xcopy /y "%QT_TOOLS_DIR%\..\bin\lib*.dll" ".\InnoSetup\build\" xcopy /y "%QT_TOOLS_DIR%\..\lib\lib*.dll" ".\InnoSetup\build\" diff --git a/src/UI_YUVviewer.ui b/src/UI_YUVviewer.ui index 540d38b..f292b38 100644 --- a/src/UI_YUVviewer.ui +++ b/src/UI_YUVviewer.ui @@ -229,6 +229,11 @@ BayerGR_RAW16 + + + PNG + + diff --git a/src/YUVdecoder.cpp b/src/YUVdecoder.cpp index 40b6948..1f71594 100644 --- a/src/YUVdecoder.cpp +++ b/src/YUVdecoder.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include "YUVdecoder.h" @@ -48,6 +49,7 @@ QMap ImageDecoder::yuvdecoder_map = { {"BayerGB_RAW16", BAYER_FUNC(cv::COLOR_BayerGB2RGB,16)}, {"BayerRG_RAW16", BAYER_FUNC(cv::COLOR_BayerRG2RGB,16)}, {"BayerGR_RAW16", BAYER_FUNC(cv::COLOR_BayerGR2RGB,16)}, + {"PNG", ImageDecoder::png}, }; QList ImageDecoder::yv12(const QString &yuvfilename,int W, int H, int startframe, int totalframe) { @@ -430,3 +432,17 @@ QList ImageDecoder::bayer(const QString &yuvfilename,int W, int H, int return rgbImglist; } + +QList ImageDecoder::png(const QString &yuvfilename,int W, int H, int startframe, int totalframe) { + QList rgbImglist; + + cv::Mat *rgbImg = new cv::Mat; + *rgbImg = cv::imread(yuvfilename.toStdString()); + rgbImglist.insert(rgbImglist.constEnd(), rgbImg); + + Q_UNUSED(W); + Q_UNUSED(H); + Q_UNUSED(startframe); + Q_UNUSED(totalframe); + return rgbImglist; +} diff --git a/src/YUVdecoder.h b/src/YUVdecoder.h index 9803d56..4ca818b 100644 --- a/src/YUVdecoder.h +++ b/src/YUVdecoder.h @@ -29,6 +29,7 @@ class ImageDecoder { static QList bgr565_big_endian(const QString &yuvfilename,int W, int H, int startframe, int totalframe); static QList rgb888(const QString &yuvfilename,int W, int H, int startframe, int totalframe); static QList bayer(const QString &yuvfilename,int W, int H, int startframe, int totalframe,int code,int bit); + static QList png(const QString &yuvfilename,int W, int H, int startframe, int totalframe); static QMap yuvdecoder_map; }; diff --git a/src/YUVviewer.cpp b/src/YUVviewer.cpp index 899e2b6..3fef00e 100644 --- a/src/YUVviewer.cpp +++ b/src/YUVviewer.cpp @@ -133,6 +133,7 @@ const QList>> YUVviewer::YUVFormat_ UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B}}, {"BayerGR_RAW16", {UI_G,UI_G,UI_R,UI_R,UI_G,UI_G,UI_R,UI_R,UI_G,UI_G,UI_R,UI_R,UI_G,UI_G,UI_R,UI_R,UI_G,UI_G,UI_R,UI_R,UI_G,UI_G,UI_R,UI_R, UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G,UI_B,UI_B,UI_G,UI_G}}, + {"PNG", {UI_A}}, }; YUVviewer::YUVviewer(QWidget *parent) : @@ -583,7 +584,7 @@ void YUVviewer::openFile() { if(lastPath.isDir()) { openDir = YUVviewerConfigFile->config_dict.lastPath; } - QStringList openfile_list = QFileDialog::getOpenFileNames(this, "选择文件", openDir, "YUV files(*.yuv *.data *.raw)"); + QStringList openfile_list = QFileDialog::getOpenFileNames(this, "选择文件", openDir, "files(*.yuv *.data *.raw *.png)"); if(openfile_list.size() != 0) { QFileInfo file(openfile_list[0]); YUVviewerConfigFile->config_dict.lastPath = file.absolutePath(); @@ -603,7 +604,7 @@ void YUVviewer::openFolder() { if (!openfolder_name.isEmpty()) { YUVviewerConfigFile->config_dict.lastPath = openfolder_name; QDir dir(openfolder_name); - QStringList nameFilters = {"*.yuv","*.data","*.raw"}; + QStringList nameFilters = {"*.yuv","*.data","*.raw","*.png"}; QStringList openfilename_list = dir.entryList(nameFilters, QDir::Files|QDir::Readable, QDir::Name); QStringList openfile_list; foreach (QString file_name, openfilename_list) { diff --git a/test/640x480.png b/test/640x480.png new file mode 100644 index 0000000000000000000000000000000000000000..f10f048917204cc0705bc675c63aeef8ccc67476 GIT binary patch literal 323850 zcmV)2K+M01P)xS#Qk3v(l3EPOc=l=FhEc5iWxX@ ze9Wq~clW~&8Fa5*l}enG&vx+t_+S5L004l&4DSjdzOAzh77b$6Liw;OT*3KK3qNnU ztoc_TDB06?Y<(9IGySge@LLuqEiJ(=Adr}Eq-NK-wupO?_x zKv~<3h?wd0MGXKyrinkNbN_M+&k^XSfPKngyul{N!py)m;&|S|&sn0s%KF%L4s%sL z{d8!d@l$vG=rEm7t!!VthYdF~^aKS@>ON{5SGF)d!H9Ms0f75{w2O%FFY(_zKG4!jOXkZq!az8485ePx1lnJnXA&;rVnm9PVK%ep0$wEa#_#p_@!3;xX*t$ISpR z9&*fx>(loiv=Yoc434;W%Renu3wy|KV3Qdb0E0K@E3>NzPU^_pS_tcfw)`-+K%b!X z-6uquRiHpbS@FZv@)!nzj`cZniNpH+%=q>;^EPYF=T)=2uUlKAQ7@>{+I^;w;btq!zrb`ai2ktUKVpQ}O#Ue~W?MNb zUEj6v|GCmldtI5C?;9$cLdN{h`RGH*y!jZ+TtH3qR8aUx{m2Y5_{6 z&8tnQ5yWTnbKi*z27vEwPFjOfWF(YT=lTGfywW+LUJ&or=($ArXmp6od|fRy%8mRz z(~oWWyhXd6`E!NMlSw-__;5k_Q)A*^EA26_7@fhK!G5lI=qeKJgD_7$GgZ3Y?(?>0 zKKnePzUTk^-=+;%ctG?AJAGgDRI0-M-ck7obA5CwdX@d7mj8&}wJe`%EVCBz19cPE z3ccPc@wD*)HO7B_gt`*+$@!rzfn7TTU+N5)xgS4K{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