Ejemplo n.º 1
0
    def compute_reproj_err(self):


        def l1loss(label, pred, v_weight=None):
            diff = tf.abs(label - pred)
            #diff = tf.where(tf.is_inf(diff), tf.zeros_like(diff), diff)
            #diff = tf.where(tf.is_nan(diff), tf.zeros_like(diff), diff)
            div = tf.count_nonzero(diff,dtype=tf.float32)
            # div = tf.count_nonzero(diff,dtype=tf.float32)
            if v_weight is not None:
                diff = tf.multiply(diff, v_weight)

            if v_weight is not None:
                return tf.reduce_sum(diff)/(tf.count_nonzero(v_weight,dtype=tf.float32)+0.000000001)
            else:
                return tf.reduce_sum(diff)/(div+0.000000001)


        proj_img, wmask, flow = projective_inverse_warp(
            self.keyframe_tf,
            1.0/tf.squeeze( self.pred_depth, axis=3),
            self.pred_pose,
            self.intrinsics_tf,
            format='eular'
        )

        self.reproj_loss = l1loss(self.image_tf, 
                                  proj_img,
                                  wmask)
Ejemplo n.º 2
0
    def proj_img(self, R, T, image, depth, matK):

        filler = tf.constant([0.0, 0.0, 0.0, 1.0], shape=[1, 1, 4])
        filler = tf.tile(filler, [1, 1, 1])
        transform_mat = tf.concat([R, T], axis=2)
        transform_mat = tf.concat([transform_mat, filler], axis=1)
        output_img, _, _, _, _ = utlr.projective_inverse_warp(image,
                                                              depth,
                                                              transform_mat,
                                                              matK,
                                                              format='matrix')
        tf.summary.image('proj' , \
                        output_img)
        tf.summary.image('tgt' , \
                        image)
        self.output_img = output_img