Skip to content

dense: check and resize the existed dmap file to image#1024

Open
thomas-19 wants to merge 2 commits into
cdcseacave:developfrom
thomas-19:develop
Open

dense: check and resize the existed dmap file to image#1024
thomas-19 wants to merge 2 commits into
cdcseacave:developfrom
thomas-19:develop

Conversation

@thomas-19

Copy link
Copy Markdown

for issue #1014 : add size check for existed depthmap and image. If their size not match, resize the depthmap to image size.

Comment thread libs/MVS/SceneDensify.cpp Outdated
Comment thread libs/MVS/SceneDensify.cpp Outdated
Comment thread libs/MVS/SceneDensify.cpp Outdated
Comment thread libs/MVS/SceneDensify.cpp Outdated
@thomas-19 thomas-19 requested a review from cdcseacave July 16, 2023 05:49
Comment thread libs/MVS/DepthMap.cpp
} // ImportDepthDataRaw
/*----------------------------------------------------------------*/

bool MVS::GetDepthMapHeaderSize(const String& fileName, cv::Size& size)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a interesting exercise, but function ImportDepthDataRaw() already existing could be already used for this if you set flags param to 0, pls check

@cdcseacave cdcseacave Jul 16, 2023

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want you can still let this function, but instead of duplicating the code just call ImportDepthDataRaw and return the only the sizes;

more useful will be to rename it to std::optional<std::pair<cv::Size, cv::Size>> GetDepthMapHeaderSizes(const String& fileName) and return both image and depth-map sizes

Comment thread libs/MVS/SceneDensify.cpp
depthData.Load(depthMapName);
DepthMap& depthMap = depthData.depthMap;
cv::resize(depthMap, depthMap, data.scene.images[idx].GetSize(), 0, 0, cv::INTER_NEAREST);
depthData.Save(depthMapName);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is ok if you use depthData to load the depth-map, but after saving it back to disk you should release it from depthData as well

and you can combine this with the next check that loads the depth-map, and if we that check is true we do not release it

Comment thread libs/MVS/SceneDensify.cpp
if (GetDepthMapHeaderSize(depthMapName, depthMapSize) && depthMapSize != data.scene.images[idx].GetSize()) {
depthData.Load(depthMapName);
DepthMap& depthMap = depthData.depthMap;
cv::resize(depthMap, depthMap, data.scene.images[idx].GetSize(), 0, 0, cv::INTER_NEAREST);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resizing only the depth-map is not enough, you should resize all images inside, ex normal-map, etc

Comment thread libs/MVS/SceneDensify.cpp
if (OPTDENSE::nOptimize & OPTDENSE::OPTIMIZE) {
if (!depthData.Load(ComposeDepthFilePath(depthData.GetView().GetID(), "dmap"))) {
VERBOSE("error: invalid depth-map '%s'", ComposeDepthFilePath(depthData.GetView().GetID(), "dmap").c_str());
if (!depthData.Load(depthMapName)) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make this compatible with the above change, modify the if like:

if (depthData.IsEmpty() && !depthData.Load(depthMapName)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants