yanconglin / VanishingPoint_HoughTransform_GaussianSphere

Official implementation: Deep vanishing point detection: Geometric priors make dataset variations vanish, CVPR'22.
MIT License
90 stars 9 forks source link

About fibonacci sample and polar coordinates #4

Closed shifan-Z closed 1 year ago

shifan-Z commented 2 years ago

Thanks for posting your excellent code! I have some problems when reading the code.

  1. could you please show me the formula of the Fibonacci lattice you uesd? I found one online, shown later, but it doesn't match the code. Or maybe I have wrong understanding. image https://github.com/yanconglin/VanishingPoint_HoughTransform_GaussianSphere/blob/0926733b1bd58531c0a50216017aa29a4cd18025/parameterization.py#L53-L62
  2. In line 100, it seems that the code used $\rho=xsin\theta + ycos\theta$, which means the $\theta$ maybe the angle between the direction of $\rho$ and positive y-axis.(the direction of y-axis is the same as the height direction of a image) https://github.com/yanconglin/VanishingPoint_HoughTransform_GaussianSphere/blob/0926733b1bd58531c0a50216017aa29a4cd18025/parameterization.py#L100 But in line 142-153, the $\theta$ may be the the angle between the direction of $\rho$ and positive x-axis. which one is right? https://github.com/yanconglin/VanishingPoint_HoughTransform_GaussianSphere/blob/0926733b1bd58531c0a50216017aa29a4cd18025/parameterization.py#L142-L153
  3. should line 410 be: theta = opt.theta andrho = opt.rho line 418 be : mapping_ht, rho_res, theta_res = hough_transform(rows, cols, theta, rho)? https://github.com/yanconglin/VanishingPoint_HoughTransform_GaussianSphere/blob/0926733b1bd58531c0a50216017aa29a4cd18025/parameterization.py#L410-L436
  4. what is the meaning and value of the variable "vote_index_ht", I can't find in the file. https://github.com/yanconglin/VanishingPoint_HoughTransform_GaussianSphere/blob/0926733b1bd58531c0a50216017aa29a4cd18025/parameterization.py#L178-L188 Looking forward to your reply.
yanconglin commented 2 years ago

(1) Regarding the Fibanicci sampling: please refer to this. NeurVPS uses a slightly different sampling (the constant bias term).

(2) Check this tutorial on OpenGL and to_pixel function in NerVPS. It is indeed confusing. If I remember correctly (vaguely), y is pointing up in both cases. Let me know if the confusion remains.

(3) I am afraid you are wrong. The outputs are a list (array) of rhos/thetas used to sample a grid, rather than the rho_res or theta_res where "res" indicate resolution

(4) em, it seems "vote_index_ht" should have been replaced by "mapping_ht". Before releasing code, I used a slightly different naming convention. Sorry for the confusion. The commented lines are for debug or visualization only.

shifan-Z commented 2 years ago

Thank you so much to be so patient. I have already understand the reply to question(1) and (4). I still have some problems with question (2) and (3).
(2)Sorry, I am still confused. In line 100, coords is [x,y], whose shape is $[rowls*cols]\times2,$ sin_cos is $[sin\theta, cos\theta]$, whose shape is $2\times180$. So the coords @ sin_cos is $xsin\theta+ycos\theta$. However, I thought that the $\rho$ might be $\rho = xcos\theta +ysin\theta$. https://github.com/yanconglin/VanishingPoint_HoughTransform_GaussianSphere/blob/0926733b1bd58531c0a50216017aa29a4cd18025/parameterization.py#L93-L100 (3)So because of the first appearance of the variable theta_res in function main is in line 410: theta_res = opt.theta_res. Should the line484 to 485 be : theta_res and rho_res ? Otherwise these two variables are not defined. https://github.com/yanconglin/VanishingPoint_HoughTransform_GaussianSphere/blob/0926733b1bd58531c0a50216017aa29a4cd18025/parameterization.py#L408-L413 https://github.com/yanconglin/VanishingPoint_HoughTransform_GaussianSphere/blob/0926733b1bd58531c0a50216017aa29a4cd18025/parameterization.py#L475-L490 Looking forward to your reply.

yanconglin commented 2 years ago

Regarding (3): I see. you are right. they are indeed typos. Fixed now. Many thanks!

yanconglin commented 2 years ago

Regarding (4): coords = np.concatenate((coords_r[:,None], coords_w[:,None]), axis=1).astype(np.float32) is the concatenation of row indices and column indices, where row indices are y and column indices are x.

Hough Transform: rho = x cos + y sin. In the code: vote_map = (coords @ sin_cos).astype(np.float32), which is rho = row_id sin + col_id cos, or equivalently rho = y sin + x cos.

The (x-y) and (col-row) conversion is tricky there. row/col differs from x/y (image plane vs Cartesian coordinate).

shifan-Z commented 2 years ago

Thank you so much. I got it !