Skip to content

Commit d3f38a5

Browse files
authored
Merge pull request #2017 from alicevision/dev/adaptativeScaleDepthmaps
Enable depthmaps with different resolution than input
2 parents bb98bb1 + 6950abd commit d3f38a5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/software/utils/main_depthmapTracksInjecting.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,28 @@ int aliceVision_main(int argc, char** argv)
101101
continue;
102102
}
103103

104+
int swidth = view->getImage().getWidth();
105+
int sheight = view->getImage().getHeight();
106+
107+
double scaleW = 1.0;
108+
double scaleH = 1.0;
109+
if (depthImg.width() != swidth || depthImg.height() != sheight)
110+
{
111+
ALICEVISION_LOG_INFO("Depth image has a different size than the input image");
112+
scaleW = double(depthImg.width()) / double(swidth);
113+
scaleH = double(depthImg.height()) / double(sheight);
114+
ALICEVISION_LOG_INFO("Relative scale : (" << scaleW << ","<< scaleH <<")");
115+
}
116+
104117
ALICEVISION_LOG_INFO("Injecting from " << depthPath);
105118
for (const auto & trackId: tracksPerView.at(idView))
106119
{
107120
track::Track & track = tracks[trackId];
108121

109122
auto & feature = track.featPerView.at(idView);
110123

111-
int ix = int(feature.coords.x());
112-
int iy = int(feature.coords.y());
124+
int ix = int(scaleW * feature.coords.x());
125+
int iy = int(scaleH * feature.coords.y());
113126

114127
if (ix < 0 || ix >= depthImg.width()) continue;
115128
if (iy < 0 || iy >= depthImg.height()) continue;

0 commit comments

Comments
 (0)