@@ -663,130 +663,57 @@ void DepthEstimator::ProcessPixel(IDX idx)
663
663
#if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
664
664
neighborsClose.Empty ();
665
665
#endif
666
- if (dir == LT2RB) {
667
- // direction from left-top to right-bottom corner
668
- if (x0.x > nSizeHalfWindow) {
669
- const ImageRef nx (x0.x -1 , x0.y );
670
- const Depth ndepth (depthMap0 (nx));
671
- if (ndepth > 0 ) {
672
- #if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
673
- ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ));
674
- neighbors.emplace_back (nx);
675
- neighborsClose.emplace_back (NeighborEstimate{ndepth,normalMap0 (nx)
676
- #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
677
- , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
678
- #endif
679
- });
680
- #else
681
- neighbors.emplace_back (NeighborData{nx,ndepth,normalMap0 (nx)});
666
+ const auto AddDirectionNeighbor = [this ] (const ImageRef& nx) {
667
+ const Depth ndepth (depthMap0 (nx));
668
+ if (ndepth > 0 ) {
669
+ #if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
670
+ ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ), " Norm = " , norm (normalMap0 (nx)));
671
+ neighbors.emplace_back (nx);
672
+ neighborsClose.emplace_back (NeighborEstimate{ndepth, normalMap0 (nx)
673
+ #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
674
+ , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
682
675
#endif
683
- }
676
+ });
677
+ #else
678
+ neighbors.emplace_back (NeighborData{nx,ndepth,normalMap0 (nx)});
679
+ #endif
684
680
}
685
- if (x0.y > nSizeHalfWindow) {
686
- const ImageRef nx (x0.x , x0.y -1 );
687
- const Depth ndepth (depthMap0 (nx));
688
- if (ndepth > 0 ) {
689
- #if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
690
- ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ));
691
- neighbors.emplace_back (nx);
692
- neighborsClose.emplace_back (NeighborEstimate{ndepth,normalMap0 (nx)
693
- #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
694
- , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
695
- #endif
696
- });
697
- #else
698
- neighbors.emplace_back (NeighborData{nx,ndepth,normalMap0 (nx)});
681
+ };
682
+ const auto AddDirection = [this ] (const ImageRef& nx) {
683
+ const Depth ndepth (depthMap0 (nx));
684
+ if (ndepth > 0 ) {
685
+ ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ), " Norm = " , norm (normalMap0 (nx)));
686
+ neighborsClose.emplace_back (NeighborEstimate{ndepth, normalMap0 (nx)
687
+ #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
688
+ , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
699
689
#endif
700
- }
701
- }
702
- #if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
703
- if (x0.x < size.width -nSizeHalfWindow) {
704
- const ImageRef nx (x0.x +1 , x0.y );
705
- const Depth ndepth (depthMap0 (nx));
706
- if (ndepth > 0 ) {
707
- ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ));
708
- neighborsClose.emplace_back (NeighborEstimate{ndepth,normalMap0 (nx)
709
- #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
710
- , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
711
- #endif
712
- });
713
- }
714
- }
715
- if (x0.y < size.height -nSizeHalfWindow) {
716
- const ImageRef nx (x0.x , x0.y +1 );
717
- const Depth ndepth (depthMap0 (nx));
718
- if (ndepth > 0 ) {
719
- ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ));
720
- neighborsClose.emplace_back (NeighborEstimate{ndepth,normalMap0 (nx)
721
- #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
722
- , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
723
- #endif
724
690
});
725
- }
726
691
}
692
+ };
693
+ if (dir == LT2RB) {
694
+ // direction from left-top to right-bottom corner
695
+ if (x0.x > nSizeHalfWindow)
696
+ AddDirectionNeighbor (ImageRef (x0.x -1 , x0.y ));
697
+ if (x0.y > nSizeHalfWindow)
698
+ AddDirectionNeighbor (ImageRef (x0.x , x0.y -1 ));
699
+ #if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
700
+ if (x0.x < size.width -nSizeHalfWindow)
701
+ AddDirection (ImageRef (x0.x +1 , x0.y ));
702
+ if (x0.y < size.height -nSizeHalfWindow)
703
+ AddDirection (ImageRef (x0.x , x0.y +1 ));
727
704
#endif
728
705
} else {
729
706
ASSERT (dir == RB2LT);
730
707
// direction from right-bottom to left-top corner
731
- if (x0.x < size.width -nSizeHalfWindow) {
732
- const ImageRef nx (x0.x +1 , x0.y );
733
- const Depth ndepth (depthMap0 (nx));
734
- if (ndepth > 0 ) {
735
- #if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
736
- ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ));
737
- neighbors.emplace_back (nx);
738
- neighborsClose.emplace_back (NeighborEstimate{ndepth,normalMap0 (nx)
739
- #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
740
- , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
741
- #endif
742
- });
743
- #else
744
- neighbors.emplace_back (NeighborData{nx,ndepth,normalMap0 (nx)});
745
- #endif
746
- }
747
- }
748
- if (x0.y < size.height -nSizeHalfWindow) {
749
- const ImageRef nx (x0.x , x0.y +1 );
750
- const Depth ndepth (depthMap0 (nx));
751
- if (ndepth > 0 ) {
752
- #if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
753
- ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ));
754
- neighbors.emplace_back (nx);
755
- neighborsClose.emplace_back (NeighborEstimate{ndepth,normalMap0 (nx)
756
- #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
757
- , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
758
- #endif
759
- });
760
- #else
761
- neighbors.emplace_back (NeighborData{nx,ndepth,normalMap0 (nx)});
762
- #endif
763
- }
764
- }
708
+ if (x0.x < size.width -nSizeHalfWindow)
709
+ AddDirectionNeighbor (ImageRef (x0.x +1 , x0.y ));
710
+ if (x0.y < size.height -nSizeHalfWindow)
711
+ AddDirectionNeighbor (ImageRef (x0.x , x0.y +1 ));
765
712
#if DENSE_SMOOTHNESS != DENSE_SMOOTHNESS_NA
766
- if (x0.x > nSizeHalfWindow) {
767
- const ImageRef nx (x0.x -1 , x0.y );
768
- const Depth ndepth (depthMap0 (nx));
769
- if (ndepth > 0 ) {
770
- ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ));
771
- neighborsClose.emplace_back (NeighborEstimate{ndepth,normalMap0 (nx)
772
- #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
773
- , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
774
- #endif
775
- });
776
- }
777
- }
778
- if (x0.y > nSizeHalfWindow) {
779
- const ImageRef nx (x0.x , x0.y -1 );
780
- const Depth ndepth (depthMap0 (nx));
781
- if (ndepth > 0 ) {
782
- ASSERT (ISEQUAL (norm (normalMap0 (nx)), 1 .f ));
783
- neighborsClose.emplace_back (NeighborEstimate{ndepth,normalMap0 (nx)
784
- #if DENSE_SMOOTHNESS == DENSE_SMOOTHNESS_PLANE
785
- , Cast<float >(image0.camera .TransformPointI2C (Point3 (nx, ndepth)))
786
- #endif
787
- });
788
- }
789
- }
713
+ if (x0.x > nSizeHalfWindow)
714
+ AddDirection (ImageRef (x0.x -1 , x0.y ));
715
+ if (x0.y > nSizeHalfWindow)
716
+ AddDirection (ImageRef (x0.x , x0.y -1 ));
790
717
#endif
791
718
}
792
719
float & conf = confMap0 (x0);
@@ -1027,7 +954,7 @@ DepthEstimator::PixelEstimate DepthEstimator::PerturbEstimate(const PixelEstimat
1027
954
}
1028
955
perturbation *= 0 .5f ;
1029
956
}
1030
- ASSERT (ISEQUAL (norm (ptbEst.normal ), 1 .f ));
957
+ ASSERT (ISEQUAL (norm (ptbEst.normal ), 1 .f ), " Norm = " , norm (ptbEst. normal ) );
1031
958
1032
959
return ptbEst;
1033
960
}
0 commit comments