Skip to content

Commit

Permalink
移除opencv读取图像的分辨率限制
Browse files Browse the repository at this point in the history
  • Loading branch information
jark006 committed Oct 25, 2024
1 parent b2a932a commit 5f4c9e6
Show file tree
Hide file tree
Showing 8 changed files with 2,213 additions and 9 deletions.
22 changes: 18 additions & 4 deletions jarkViewer/include/ImageDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "src/wp2/base.h"
#include "src/wp2/decode.h"
#include "libbpg.h"
#include "thorvg.h"

#pragma comment(lib, "IlmImf.lib")
#pragma comment(lib, "ippiw.lib")
Expand Down Expand Up @@ -71,7 +72,9 @@
#pragma comment(lib, "plutovg.lib")
#pragma comment(lib, "webp2.lib")
#pragma comment(lib, "imageio.lib")
//#pragma comment(lib, "thorvg.lib")

// meson setup builddir --backend=vs --buildtype release -Dloaders="all" -Dtools="all"
#pragma comment(lib, "thorvg-0.lib")

// .\gswin64c.exe -dNOPAUSE -dBATCH -sDEVICE=png16m -r300 -sOutputFile=d:\aa.png "D:\Downloads\test\perth.eps"

Expand All @@ -84,7 +87,7 @@ class ImageDatabase:public LRU<wstring, Frames> {
L".exr", L".tiff", L".tif", L".webp", L".hdr", L".pic",
L".heic", L".heif", L".avif", L".avifs", L".gif", L".jxl",
L".ico", L".icon", L".psd", L".tga", L".svg", L".jfif",
L".jxr", L".wp2", L".pfm",L".bpg",
L".jxr", L".wp2", L".pfm",L".bpg",
};

static inline const unordered_set<wstring> supportRaw {
Expand All @@ -102,6 +105,10 @@ class ImageDatabase:public LRU<wstring, Frames> {
L".3fr" // Hasselblad
};

ImageDatabase() {
setCapacity(3);
}

cv::Mat errorTipsMat, homeMat;

cv::Mat& getErrorTipsMat() {
Expand Down Expand Up @@ -374,7 +381,7 @@ class ImageDatabase:public LRU<wstring, Frames> {
return frames;
}

JxlBasicInfo info;
JxlBasicInfo info{};
JxlPixelFormat format = { 4, JXL_TYPE_UINT8, JXL_NATIVE_ENDIAN, 0 };

JxlDecoderSetInput(dec.get(), buf.data(), buf.size());
Expand Down Expand Up @@ -1323,7 +1330,14 @@ class ImageDatabase:public LRU<wstring, Frames> {
}

cv::Mat loadMat(const wstring& path, const vector<uchar>& buf) {
auto img = cv::imdecode(buf, cv::IMREAD_UNCHANGED);
cv::Mat img;
try{
img = cv::imdecode(buf, cv::IMREAD_UNCHANGED);
}
catch (cv::Exception e) {
Utils::log("cvMat cannot decode: {} [{}]", Utils::wstringToUtf8(path), e.what());
return cv::Mat();
}

if (img.empty()) {
Utils::log("cvMat cannot decode: {}", Utils::wstringToUtf8(path));
Expand Down
4 changes: 2 additions & 2 deletions jarkViewer/include/LRU.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class LRU {
}

void setCapacity(size_t capacity) {
if (capacity < 10 || capacity > 4096)
capacity = 20;
if (capacity < 3 || capacity > 4096)
capacity = 3;
CAPACITY = capacity;
}

Expand Down
Loading

0 comments on commit 5f4c9e6

Please sign in to comment.