Open jamesfisher-geo opened 2 years ago
the depth-map PNGs are only colored versions of the depth-maps, not the actual depth values
you should use the DMAP files instead by using the Interface.h
; they also contain the ID of the image it corresponds to
Thank you for the clarification and for the great software package. My updated goal is now to make an executable that will read in a .dmap
file and output the raw depth arrays.
It looks like this can be done with the HeaderDepthDataRaw
struct and ExportDepthDataRaw
function from Interface.h
and Depthmap.cpp
, respectively.
However, I am a confused on how to call ExportDepthDataRaw
as the inputs are (const String& fileName, const String& imageFileName, const IIndexArr& IDs, const cv::Size& imageSize, const KMatrix& K, const RMatrix& R, const CMatrix& C, Depth dMin, Depth dMax, const DepthMap& depthMap, const NormalMap& normalMap, const ConfidenceMap& confMap)
Rather than just the .dmap
file.
Any guidance here would be much appreciated.
sure, check how it is called in other parts of OpenMVS
#include <iostream>
#include <vector>
#include<iostream>
#include<fstream>
using namespace std;
struct HeaderDepthDataRaw {
enum {
HAS_DEPTH = (1<<0),
HAS_NORMAL = (1<<1),
HAS_CONF = (1<<2),
};
uint16_t name; // file type
uint8_t type; // content type
uint8_t padding; // reserve
uint32_t imageWidth, imageHeight; // image resolution
uint32_t depthWidth, depthHeight; // depth-map resolution
float dMin, dMax; // depth range for this view
inline HeaderDepthDataRaw() : name(0), type(0), padding(0) {}
static uint16_t HeaderDepthDataRawName() { return *reinterpret_cast<const uint16_t*>("DR"); }
};
int main()
{
FILE *f = fopen("..//floor33//opensfm//undistorted//openmvs//depthmaps//depth0000.dmap", "rb");
HeaderDepthDataRaw header;
fread(&header, sizeof(HeaderDepthDataRaw), 1, f);
uint16_t nFileNameSize;
fread(&nFileNameSize, sizeof(uint16_t), 1, f);
std::cout << nFileNameSize << std::endl;
string imageFileName;
imageFileName.resize(nFileNameSize);
fread(&imageFileName[0u], sizeof(char), nFileNameSize, f);
imageFileName.resize(nFileNameSize);
size_t found = imageFileName.find("DT_VID");
string short_name = imageFileName.substr(found, imageFileName.length()-found);
short_name = short_name.replace(short_name.length()-3,3,"csv");
std::cout << short_name << std::endl;
fread(&imageFileName[0u], sizeof(char), nFileNameSize, f);
float depthMap[header.depthHeight][header.depthWidth] ;
fread(depthMap, sizeof(float),header.depthHeight * header.depthWidth , f);
ofstream fw(short_name, std::ofstream::out);
if (fw.is_open())
{
//store array contents to text file
for (int i = 0; i < header.depthHeight; i++) {
for(int k = 0; k< header.depthWidth; k++){
fw << depthMap[i][k] << ",";
}
fw << "\n";
}
}
fw.close();
}
#include <iostream> #include <vector> #include<iostream> #include<fstream> using namespace std; struct HeaderDepthDataRaw { enum { HAS_DEPTH = (1<<0), HAS_NORMAL = (1<<1), HAS_CONF = (1<<2), }; uint16_t name; // file type uint8_t type; // content type uint8_t padding; // reserve uint32_t imageWidth, imageHeight; // image resolution uint32_t depthWidth, depthHeight; // depth-map resolution float dMin, dMax; // depth range for this view inline HeaderDepthDataRaw() : name(0), type(0), padding(0) {} static uint16_t HeaderDepthDataRawName() { return *reinterpret_cast<const uint16_t*>("DR"); } }; int main() { FILE *f = fopen("..//floor33//opensfm//undistorted//openmvs//depthmaps//depth0000.dmap", "rb"); HeaderDepthDataRaw header; fread(&header, sizeof(HeaderDepthDataRaw), 1, f); uint16_t nFileNameSize; fread(&nFileNameSize, sizeof(uint16_t), 1, f); std::cout << nFileNameSize << std::endl; string imageFileName; imageFileName.resize(nFileNameSize); fread(&imageFileName[0u], sizeof(char), nFileNameSize, f); imageFileName.resize(nFileNameSize); size_t found = imageFileName.find("DT_VID"); string short_name = imageFileName.substr(found, imageFileName.length()-found); short_name = short_name.replace(short_name.length()-3,3,"csv"); std::cout << short_name << std::endl; fread(&imageFileName[0u], sizeof(char), nFileNameSize, f); float depthMap[header.depthHeight][header.depthWidth] ; fread(depthMap, sizeof(float),header.depthHeight * header.depthWidth , f); ofstream fw(short_name, std::ofstream::out); if (fw.is_open()) { //store array contents to text file for (int i = 0; i < header.depthHeight; i++) { for(int k = 0; k< header.depthWidth; k++){ fw << depthMap[i][k] << ","; } fw << "\n"; } } fw.close(); }
hello, I use your code to process raw value of depth map. but my matrix have some value 0 and Nan, what is value mean?
you can just include Interface.h
file, and use it.
0 value means invalid depth (does not exist an estimate)
you can just include
Interface.h
file, and use it.0 value means invalid depth (does not exist an estimate)
how about nan and -nan value? . Maximun value is 3e+34 and min is -3.4e+34, this value is distance from camera to pixel in real world? in meter or minimeter?
there should not exist any NaN values, that is an error
how about 3e+34 and -3.4e+34 value
How about them?
On Wed, 10 May 2023 at 14:08 tradinh @.***> wrote:
how about 3e+34 and -3.4e+34 value
— Reply to this email directly, view it on GitHub https://github.com/cdcseacave/openMVS/issues/805#issuecomment-1541964062, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVMH3WRKOWMBIJYUBAATATXFNZKTANCNFSM5THUJL5Q . You are receiving this because you commented.Message ID: @.***>
How about them? … On Wed, 10 May 2023 at 14:08 tradinh @.> wrote: how about 3e+34 and -3.4e+34 value — Reply to this email directly, view it on GitHub <#805 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVMH3WRKOWMBIJYUBAATATXFNZKTANCNFSM5THUJL5Q . You are receiving this because you commented.Message ID: @.>
depth map have 3e+34 and -3.4e+34 value , i dont think this is a bug, you can read my topic in opendronemap community https://community.opendronemap.org/t/convert-dmap-to-png/15431/9?u=trand2k
it might be a bug, it does not seem realistic we can measure depths of 3e+34 from photos; pls debug or share a small dataset that reproduces the issue
this is my data i gen from -v 4 option https://drive.google.com/drive/folders/1tY4LM90gRRmpyeVOgoX2vzOIwR1SrOWF?usp=sharing I use this code for reading depth image from .dmap file https://github.com/cdcseacave/openMVS/issues/805#issuecomment-1167057197 Please help me explain this value, thank you so much,
this is my data i gen from -v 4 option https://drive.google.com/drive/folders/1tY4LM90gRRmpyeVOgoX2vzOIwR1SrOWF?usp=sharing I use this code for reading depth image from .dmap file https://github.com/cdcseacave/openMVS/issues/805#issuecomment-1167057197 Please help me explain this value, thank you so much,
How to generate a depth map with openmvs' -v 4 option, I can't find it
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Hello, I am working on an application to measure off RGB images by utilizing their respective depth maps.
I am running a slightly modified build of OpenDroneMap and calling DensifyPointCloud with the following:
\"C:\\ODM\\SuperBuild\\install\\bin\\OpenMVS\\DensifyPointCloud\" "scene.mvs" --resolution-level 3 --min-resolution 1024 --max-resolution 8192 --max-threads 16 --number-views-fuse 2 -w "depthmap-directory" -v 4"
This exports the depth maps as
.png
with the following formatdepthXXXX.png
. Where XXXX is the ID of the image assigned by OpenMVS.My problem is that I want to work with these depth maps outside of OpenMVS but have no way of connecting the output depth map
depthXXXX.png
with the associated RGB image (e.g.DJI_1234.jpg
).Describe the solution you'd like
I am wondering if someone could point me in the right direction to modify the code to preserve the original filenames when exporting depth maps to
.png
.Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Alternatively, if someone could provide more information on how image IDs are assigned; and if there is a way to parse
.dmap
files in Python to extract the source image filename.Thank you.