Skip to content

Commit

Permalink
src:add png file import
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Feb 10, 2023
1 parent a414931 commit 13f41a4
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions YUVviewer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions build_dmg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions build_setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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\"
Expand Down
5 changes: 5 additions & 0 deletions src/UI_YUVviewer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@
<string>BayerGR_RAW16</string>
</property>
</item>
<item>
<property name="text">
<string>PNG</string>
</property>
</item>
</widget>
</item>
<item>
Expand Down
16 changes: 16 additions & 0 deletions src/YUVdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QtEndian>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>
#include "YUVdecoder.h"
Expand Down Expand Up @@ -48,6 +49,7 @@ QMap<QString, ImageDecoder::yuvdecoder_t> 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<cv::Mat*> ImageDecoder::yv12(const QString &yuvfilename,int W, int H, int startframe, int totalframe) {
Expand Down Expand Up @@ -430,3 +432,17 @@ QList<cv::Mat*> ImageDecoder::bayer(const QString &yuvfilename,int W, int H, int

return rgbImglist;
}

QList<cv::Mat*> ImageDecoder::png(const QString &yuvfilename,int W, int H, int startframe, int totalframe) {
QList<cv::Mat*> 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;
}
1 change: 1 addition & 0 deletions src/YUVdecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ImageDecoder {
static QList<cv::Mat*> bgr565_big_endian(const QString &yuvfilename,int W, int H, int startframe, int totalframe);
static QList<cv::Mat*> rgb888(const QString &yuvfilename,int W, int H, int startframe, int totalframe);
static QList<cv::Mat*> bayer(const QString &yuvfilename,int W, int H, int startframe, int totalframe,int code,int bit);
static QList<cv::Mat*> png(const QString &yuvfilename,int W, int H, int startframe, int totalframe);
static QMap<QString, yuvdecoder_t> yuvdecoder_map;
};

Expand Down
5 changes: 3 additions & 2 deletions src/YUVviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const QList<QPair<QString, QList<YUVviewer::UICodePoint>>> 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) :
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
Binary file added test/640x480.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 13f41a4

Please sign in to comment.