Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcdebbba

Browse files
committed
small updates
1 parent9882eab commitcdebbba

File tree

7 files changed

+164
-42
lines changed

7 files changed

+164
-42
lines changed

‎FriedLiver/Source/Bundler.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//for debugging
1717
#include"SiftVisualization.h"
1818

19-
Bundler::Bundler(unsignedint maxNumImages,unsignedint maxNumKeysPerImage,
19+
Bundler::Bundler(unsignedint maxNumImages,unsignedint maxNumKeysPerImage,
2020
const mat4f& siftIntrinsicsInv,const CUDAImageManager* manager,bool isLocal)
2121
{
2222
//initialize sift
@@ -236,7 +236,7 @@ unsigned int Bundler::matchAndFilter()
236236
}
237237
}
238238
}//global only
239-
239+
240240
////debugging
241241
//if (usedebug) {
242242
//std::vector<EntryJ> corrs(m_siftManager->getNumGlobalCorrespondences());

‎FriedLiver/Source/Bundler.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CUDACache;
1212
classCUDAImageManager;
1313

1414

15-
//#define USE_RETRY //TODO MOVE OUT TO PARAMS
15+
#defineUSE_RETRY//TODO MOVE OUT TO PARAMS??
1616

1717
classBundler
1818
{

‎FriedLiver/Source/DepthSensing/DepthSensing.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,10 @@ void StopScanningAndExit(bool aborted = false)
931931
numValidTransforms =PoseHelper::countNumValidTransforms(trajectory);numTransforms = (unsignedint)trajectory.size();
932932
if (numValidTransforms < (unsignedint)std::round(0.5f * numTransforms)) valid =false;// not enough valid transforms
933933
std::cout <<"#VALID TRANSFORMS =" << numValidTransforms << std::endl;
934-
//((SensorDataReader*)g_depthSensingRGBDSensor)->saveToFile(saveFile, trajectory); //overwrite the original file //TODO UNCOMMENT
934+
((SensorDataReader*)g_depthSensingRGBDSensor)->saveToFile(saveFile, trajectory);//overwrite the original file
935+
936+
//if (GlobalAppState::get().s_sensorIdx == 8) ((SensorDataReader*)g_depthSensingRGBDSensor)->evaluateTrajectory(trajectory);
937+
935938
//save ply
936939
std::cout <<"[marching cubes]";
937940
StopScanningAndExtractIsoSurfaceMC(util::removeExtensions(GlobalAppState::get().s_binaryDumpSensorFile) +".ply",true);//force overwrite and existing plys
@@ -1000,7 +1003,7 @@ void CALLBACK OnD3D11FrameRender(ID3D11Device* pd3dDevice, ID3D11DeviceContext*
10001003
// Fix old frames
10011004
///////////////////////////////////////
10021005
if (GlobalBundlingState::get().s_enableGlobalTimings) {GlobalAppState::get().WaitForGPU();cudaDeviceSynchronize(); t.start(); }
1003-
reintegrate();
1006+
reintegrate();
10041007
if (GlobalBundlingState::get().s_enableGlobalTimings) {GlobalAppState::get().WaitForGPU();cudaDeviceSynchronize(); t.stop();TimingLog::getFrameTiming(true).timeReIntegrate = t.getElapsedTimeMS(); }
10051008

10061009

‎FriedLiver/Source/FriedLiver.cpp‎

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ void bundlingThreadFunc() {
150150
tOpt =std::thread(bundlingOptimizationThreadFunc);
151151
}
152152
//wait for a new input frame (LOCK IMAGE MANAGER)
153-
ConditionManager::lockImageManagerFrameReady(ConditionManager::Bundling);
153+
ConditionManager::lockImageManagerFrameReady(ConditionManager::Bundling);
154154
while (!g_imageManager->hasBundlingFrameRdy()) {
155-
ConditionManager::waitImageManagerFrameReady(ConditionManager::Bundling);
155+
ConditionManager::waitImageManagerFrameReady(ConditionManager::Bundling);
156156
}
157-
{
157+
{
158158
ConditionManager::lockBundlerProcessedInput(ConditionManager::Bundling);
159159
while (g_bundler->hasProcssedInputFrame()) {//wait until depth sensing has confirmed the last one (WAITING THAT DEPTH SENSING RELEASES ITS LOCK)
160-
ConditionManager::waitBundlerProcessedInput(ConditionManager::Bundling);
160+
ConditionManager::waitBundlerProcessedInput(ConditionManager::Bundling);
161161
}
162162
{
163163
if (g_bundler->getExitBundlingThread()) {
@@ -211,6 +211,8 @@ int main(int argc, char** argv)
211211

212212
//fileNameDescGlobalApp = "zParametersTUM.txt";
213213
//fileNameDescGlobalBundling = "zParametersBundlingTUM.txt";
214+
//fileNameDescGlobalApp = "zParametersICL.txt"; //TODO HERE ANGIE
215+
//fileNameDescGlobalBundling = "zParametersBundlingTUM.txt";
214216

215217
//fileNameDescGlobalApp = "zParametersAug.txt";
216218
//fileNameDescGlobalBundling = "zParametersBundlingAug.txt";
@@ -248,32 +250,6 @@ int main(int argc, char** argv)
248250
ParameterFileparameterFileGlobalBundling(fileNameDescGlobalBundling);
249251
GlobalBundlingState::getInstance().readMembers(parameterFileGlobalBundling);
250252

251-
//!!!DEBUGGING
252-
if (false) {
253-
//const std::string runoptDataDir = "../data/runOpt/";
254-
//RunOpt::run(runoptDataDir + "recording15.sens", runoptDataDir + "71.sift", runoptDataDir + "71-initial.trajectory");
255-
RunOpt::run("../data/sens/copyroom200.sens","debug/logs/100.sift","debug/logs/100.trajectory");
256-
std::cout <<"done!" << std::endl;
257-
getchar();
258-
return0;
259-
}
260-
if (GlobalAppState::get().s_generateVideo) { std::cout <<"remember to change raycast for top-down rendering!" << std::endl;getchar(); }
261-
if (GlobalAppState::get().s_numSolveFramesBeforeExit != (unsignedint)-1 &&GlobalAppState::get().s_sensorIdx !=8) std::cout <<"warning: overwrite trajectory/save ply not implemented for non-SensorData type sensors" << std::endl;
262-
if (false) {
263-
TestMatching test;
264-
//test.analyzeLocalOpts();
265-
//test.testGlobalDense();
266-
//test.compareDEBUG();
267-
test.debug();
268-
269-
std::cout <<"done!" << std::endl;
270-
getchar();
271-
return0;
272-
}
273-
//!!!DEBUGGING
274-
275-
//SIFTMatchFilter::init(); //TODO this is obsolete
276-
277253
DualGPU& dualGPU =DualGPU::get();//needs to be called to initialize devices
278254
dualGPU.setDevice(DualGPU::DEVICE_RECONSTRUCTION);//main gpu
279255
ConditionManager::init();

‎FriedLiver/Source/SiftGPU/SIFTMatchFilter.cpp‎

Lines changed: 131 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ void SIFTMatchFilter::filterKeyPointMatchesDEBUG(unsigned int curFrame, SIFTImag
717717
voidSIFTMatchFilter::visualizeProjError(SIFTImageManager* siftManager,const vec2ui& imageIndices,const std::vector<CUDACachedFrame>& cachedFrames,
718718
const float4x4& depthIntrinsics,const float4x4& transformCurToPrv,float depthMin,float depthMax)
719719
{
720-
#ifdefCUDACACHE_UCHAR_NORMALS
720+
#if defined(CUDACACHE_UCHAR_NORMALS) && !defined(CUDACACHE_FLOAT_NORMALS)
721721
throwMLIB_EXCEPTION("need to update to uchar4 normals");
722722
#else
723723
constunsignedint numImages = siftManager->getNumImages();
@@ -802,7 +802,7 @@ void SIFTMatchFilter::computeCorrespondencesDEBUG(unsigned int width, unsigned i
802802
constfloat* modelDepth,const float4* model,const float4* modelNormals,constfloat* modelColor,const float4x4& transform,float distThres,float normalThres,float colorThresh,
803803
const float4x4& depthIntrinsics,float depthMin,float depthMax,float& sumResidual,float& sumWeight,unsignedint& numCorr)
804804
{
805-
PointCloudf pcSrc, pcTgt;
805+
PointCloudf pcSrc, pcTgt, pcTransform;//debug vis
806806

807807
s_debugCorr.allocate(width, height);
808808
s_debugCorr.setPixels(-std::numeric_limits<float>::infinity());
@@ -859,13 +859,14 @@ void SIFTMatchFilter::computeCorrespondencesDEBUG(unsigned int width, unsigned i
859859
s_debugCorr(x, y) =length(pTransInput - pTarget);
860860
pcSrc.m_points.push_back(vec3f(pTransInput.x, pTransInput.y, pTransInput.z));
861861
pcTgt.m_points.push_back(vec3f(pTarget.x, pTarget.y, pTarget.z));
862+
vec4f debugColor =BaseImageHelper::convertDepthToRGBA(std::sqrt(x*x + y*y),0.0f,std::sqrt(width*width + height*height));//distance from top left
862863
if (d > distThres) {
863-
pcSrc.m_colors.push_back(vec4f(1.0f,0.0f,0.0f,1.0f));
864-
pcTgt.m_colors.push_back(vec4f(0.0f,1.0f,0.0f,1.0f));
864+
pcSrc.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));//vec4f(1.0f, 0.0f, 0.0f, 1.0f));
865+
pcTgt.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));//(vec4f(0.0f, 1.0f, 0.0f, 1.0f));
865866
}
866867
else {
867-
pcSrc.m_colors.push_back(vec4f(cInput));
868-
pcTgt.m_colors.push_back(vec4f(cTarget));
868+
pcSrc.m_colors.push_back(debugColor);//vec4f(cInput));
869+
pcTgt.m_colors.push_back(debugColor);//vec4f(cTarget));
869870
}
870871
}
871872
}// target depth within depth min/max
@@ -882,3 +883,127 @@ void SIFTMatchFilter::computeCorrespondencesDEBUG(unsigned int width, unsigned i
882883
//getchar();
883884
int a =5;
884885
}
886+
887+
voidSIFTMatchFilter::debugVis(const SensorData& sd,const vec2ui& imageIndices,const mat4f& transform,unsignedint subsampleFactor/*= 4*/)
888+
{
889+
constunsignedint width = sd.m_depthWidth;
890+
constunsignedint height = sd.m_depthHeight;
891+
constfloat distThres =0.15f;constfloat normalThres =0.97f;
892+
constfloat depthMin =0.4f;constfloat depthMax =4.0f;
893+
894+
PointCloudf pcSrc, pcTgt, pcTransform;//debug vis
895+
PointCloudf pcSrcColor, pcTgtColor, pcTransformColor;// debug vis
896+
897+
const mat4f depthIntrinsic = sd.m_calibrationDepth.m_intrinsic;
898+
const mat4f depthIntrinsicInv = depthIntrinsic.getInverse();
899+
DepthImage32 curDepth = sd.computeDepthImage(imageIndices.y);
900+
DepthImage32 prvDepth = sd.computeDepthImage(imageIndices.x);
901+
PointImage curCamPos = sd.computeCameraSpacePositions(depthIntrinsicInv, curDepth);
902+
PointImage prvCamPos = sd.computeCameraSpacePositions(depthIntrinsicInv, prvDepth);
903+
PointImage curNormal = sd.computeNormals(curCamPos);
904+
PointImage prvNormal = sd.computeNormals(prvCamPos);
905+
906+
ColorImageR8G8B8 curColor = sd.computeColorImage(imageIndices.y);
907+
ColorImageR8G8B8 prvColor = sd.computeColorImage(imageIndices.x);
908+
909+
Grid2<bool>marker(width, height); marker.setValues(false);
910+
911+
constfloat INVALID = -std::numeric_limits<float>::infinity();
912+
for (unsignedint y =0; y < height; y += subsampleFactor) {
913+
for (unsignedint x =0; x < width; x += subsampleFactor) {
914+
915+
const vec3f pInput =curCamPos(x, y);
916+
const vec3f nInput =curNormal(x, y);
917+
float dInput =curDepth(x, y);
918+
const vec3uc& cInput =curColor(x, y);
919+
920+
if (pInput.x != INVALID && nInput.x != INVALID && dInput >= depthMin && dInput <= depthMax) {
921+
const vec3f pTransInput = transform * pInput;
922+
const vec3f nTransInput = transform.getRotation() * nInput;
923+
924+
vec2f screenPosf =cameraToDepth(depthIntrinsic, pTransInput);
925+
vec2i screenPos =math::round(screenPosf);
926+
927+
if (screenPos.x >=0 && screenPos.y >=0 && screenPos.x < (int)width && screenPos.y < (int)height) {
928+
vec3f pTarget; vec3f nTarget; vec3uc cTarget;
929+
getBestCorrespondence1x1(screenPos, pTarget, nTarget, cTarget, prvCamPos, prvNormal, prvColor);
930+
931+
if (pTarget.x != INVALID && nTarget.x != INVALID) {
932+
float d =vec3f::dist(pTransInput, pTarget);
933+
float dNormal = nTransInput | nTarget;
934+
935+
float projInputDepth = pTransInput.z;//cameraToDepthZ(pTransInput);
936+
float tgtDepth =prvDepth(screenPos.x, screenPos.y);
937+
938+
marker((screenPos.x/subsampleFactor)*subsampleFactor, (screenPos.y/subsampleFactor)*subsampleFactor) =true;
939+
if (tgtDepth >= depthMin && tgtDepth <= depthMax) {
940+
bool b = ((tgtDepth != INVALID && projInputDepth < tgtDepth) && d > distThres);// bad matches that are known
941+
if ((dNormal >= normalThres && d <= distThres/*&& c <= colorThresh*/) || b) {// if normal/pos/color correspond or known bad match
942+
943+
pcSrc.m_points.push_back(pTransInput);
944+
pcTgt.m_points.push_back(pTarget);
945+
pcSrcColor.m_points.push_back(pTransInput);
946+
pcTgtColor.m_points.push_back(pTarget);
947+
vec4f debugColor =BaseImageHelper::convertDepthToRGBA(std::sqrt(x*x + y*y),0.0f,std::sqrt(width*width + height*height));//distance from top left
948+
if (d > distThres) {
949+
pcSrc.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));//vec4f(1.0f, 0.0f, 0.0f, 1.0f));
950+
pcTgt.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));//(vec4f(0.0f, 1.0f, 0.0f, 1.0f));
951+
pcSrcColor.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));
952+
pcTgtColor.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));
953+
}
954+
else {
955+
pcSrc.m_colors.push_back(debugColor);//vec4f(cInput));
956+
pcTgt.m_colors.push_back(debugColor);//vec4f(cTarget));
957+
pcSrcColor.m_colors.push_back(vec4f(vec3f(cInput)/255.0f));
958+
pcTgtColor.m_colors.push_back(vec4f(vec3f(cTarget)/255.0f));
959+
}
960+
}
961+
}// target depth within depth min/max
962+
}// projected to valid depth
963+
}// inside image
964+
else {
965+
pcSrc.m_points.push_back(pTransInput);
966+
pcSrc.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));
967+
pcSrcColor.m_points.push_back(pTransInput);
968+
pcSrcColor.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));
969+
}
970+
}
971+
}// x
972+
}// y
973+
974+
for (unsignedint y =0; y < height; y += subsampleFactor) {
975+
for (unsignedint x =0; x < width; x += subsampleFactor) {
976+
if (!marker(x, y)) {
977+
const vec3f& pTarget =prvCamPos(x, y);
978+
pcTgt.m_points.push_back(pTarget);
979+
pcTgt.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));
980+
pcTgtColor.m_points.push_back(pTarget);
981+
pcTgtColor.m_colors.push_back(vec4f(0.5f,0.5f,0.5f,1.0f));
982+
}
983+
}
984+
}
985+
986+
//PointCloudIOf::saveToFile("debug/src.ply", pcSrc);
987+
//PointCloudIOf::saveToFile("debug/tgt.ply", pcTgt);
988+
//PointCloudIOf::saveToFile("debug/src-color.ply", pcSrcColor);
989+
//PointCloudIOf::saveToFile("debug/tgt-color.ply", pcTgtColor);
990+
991+
MeshDataf mdSrc, mdTgt, mdSrcColor, mdTgtColor;
992+
unsignedint numSlice =8;
993+
for (unsignedint i =0; i < pcSrc.m_points.size(); i++)
994+
mdSrc.merge(Shapesf::sphere(0.01f, pcSrc.m_points[i], numSlice, numSlice, pcSrc.m_colors[i]).computeMeshData());
995+
MeshIOf::saveToFile("debug/m_src.ply", mdSrc);
996+
for (unsignedint i =0; i < pcTgt.m_points.size(); i++)
997+
mdTgt.merge(Shapesf::sphere(0.01f, pcTgt.m_points[i], numSlice, numSlice, pcTgt.m_colors[i]).computeMeshData());
998+
MeshIOf::saveToFile("debug/m_tgt.ply", mdTgt);
999+
for (unsignedint i =0; i < pcSrcColor.m_points.size(); i++)
1000+
mdSrcColor.merge(Shapesf::sphere(0.01f, pcSrcColor.m_points[i], numSlice, numSlice, pcSrcColor.m_colors[i]).computeMeshData());
1001+
MeshIOf::saveToFile("debug/m_src-color.ply", mdSrcColor);
1002+
for (unsignedint i =0; i < pcTgtColor.m_points.size(); i++)
1003+
mdTgtColor.merge(Shapesf::sphere(0.01f, pcTgtColor.m_points[i], numSlice, numSlice, pcTgtColor.m_colors[i]).computeMeshData());
1004+
MeshIOf::saveToFile("debug/m_tgt-color.ply", mdTgtColor);
1005+
1006+
//std::cout << "press key" << std::endl;
1007+
//getchar();
1008+
int a =5;
1009+
}

‎FriedLiver/Source/SiftGPU/SIFTMatchFilter.h‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class SIFTMatchFilter
3333
//generateKCombinations(20, 4, s_combinations, 128);
3434
s_bInit =true;
3535
}
36+
37+
staticvoiddebugVis(const SensorData& sd,const vec2ui& imageIndices,const mat4f& transform,unsignedint subsampleFactor =4);
3638
private:
3739
staticbool s_bInit;
3840
static std::vector<std::vector<unsignedint>> s_combinations;
@@ -92,7 +94,19 @@ class SIFTMatchFilter
9294
staticinlinefloatcameraToKinectProjZ(float z,float depthMin,float depthMax) {
9395
return (z - depthMin) / (depthMax - depthMin);
9496
}
95-
97+
static vec2fcameraToDepth(const mat4f& depthIntrinsics,const vec3f& pos)
98+
{
99+
vec3f p = depthIntrinsics * pos;
100+
returnvec2f(p.x / p.z, p.y / p.z);
101+
}
102+
staticinlinevoidgetBestCorrespondence1x1(
103+
const vec2i& screenPos, vec3f& pTarget, vec3f& nTarget, vec3uc& cTarget,
104+
const PointImage& target,const PointImage& targetNormals,const ColorImageR8G8B8& targetColor)
105+
{
106+
pTarget =target(screenPos.x, screenPos.y);
107+
nTarget =targetNormals(screenPos.x, screenPos.y);
108+
cTarget =targetColor(screenPos.x, screenPos.y);
109+
}
96110

97111
staticinlinevoidgetBestCorrespondence1x1(
98112
const int2& screenPos, float4& pTarget, float4& nTarget,float& cTarget,

‎FriedLiver/Source/Solver/CUDASolverBundling.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ void CUDASolverBundling::solve(EntryJ* d_correspondences, unsigned int numberOfC
266266
buildVariablesToCorrespondencesTable(d_correspondences, numberOfCorrespondences);
267267
}
268268

269+
//if (cudaCache) {
270+
//cudaCache->printCacheImages("debug/cache/");
271+
//int a = 5;
272+
//}
269273
solveBundlingStub(solverInput, m_solverState, parameters, m_solverExtra, convergence, m_timer);
270274

271275
if (findMaxResidual) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp