Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

singe camera case in correspondences #118

Open
alexlib opened this issue Oct 11, 2016 · 9 comments
Open

singe camera case in correspondences #118

alexlib opened this issue Oct 11, 2016 · 9 comments

Comments

@alexlib
Copy link
Contributor

alexlib commented Oct 11, 2016

In previous versions a single camera case was treated in correspondences. at least a necessary rt_is. file was written after the targets are converted to flat coordinates for the following tracking.

present version of correspondences in liboptv does not treat this case.

@alexlib
Copy link
Contributor Author

alexlib commented Mar 30, 2018

@yosefm maybe pbi has a solution the single-camera case? I think we need to add to correspondences.c this part:

  /* -------------if only one cam and 2D--------- */ //by Beat Lüthi June 2007
  if(cpar->num_cams == 1){
	  if(res_name[0]==0){
          sprintf (res_name, "rt_is");
	  }
	 fp1 = fopen (res_name, "w");
		fprintf (fp1, "%4d\n", num[0]);
	  for (i=0; i<num[0]; i++){
          o = epi_mm_2D (geo[0][i].x,geo[0][i].y,
		      Ex[0], I[0],  G[0], *(cpar->mm), vpar,
		      &X,&Y,&Z);
          pix[0][geo[0][i].pnr].tnr=i;
		  fprintf (fp1, "%4d", i+1);
		  fprintf (fp1, " %9.3f %9.3f %9.3f", X, Y, Z);
          fprintf (fp1, " %4d", geo[0][i].pnr);
          fprintf (fp1, " %4d", -1);
          fprintf (fp1, " %4d", -1);
          fprintf (fp1, " %4d\n", -1);
	  }
	  fclose (fp1);
	  match1=num[0];
  }

and concatenate match1 with other matches of pairs, triplets and quadruplets?

from https://github.com/OpenPTV/openptv-python/blob/cc690f1fd0da7a01914fdb43f18d62a2cb9aff00/src_c/correspondences.c#L67

@yosefm
Copy link
Member

yosefm commented Mar 31, 2018 via email

@alexlib
Copy link
Contributor Author

alexlib commented Mar 31, 2018

i am not sure, but maybe it's better to use epipolar.pyx instead of correspondes.c and introduce it there? I could probably bind in epipolar.pyx the epi_mm_2D that exists in epi.c and use it to fill the data structures?

@alexlib
Copy link
Contributor Author

alexlib commented Apr 2, 2018

@yosefm can you please take a look at the first attempt to get single camera solution through correspondences.pyx and epi_mm_2D binding? I'm stuck with the question on how to set up Frame 3D positions? I found in tracking_framebuf.pyx the positions () but not set_positions. What do you suggest? I'd appreciate a review of this approach. Would two if statements be Pythonic enough?

alexlib@edfcee2

@yosefm
Copy link
Member

yosefm commented Apr 3, 2018 via email

@yosefm
Copy link
Member

yosefm commented Apr 6, 2018

The approach looks fine (apart from code quality comments I left on the commit). But I don't know where you want to set_position or put those of statements. Please give me some direction as line number, example code, or something else I can find.

@alexlib
Copy link
Contributor Author

alexlib commented Apr 6, 2018

Left you a comment on that line. from epi_mm_2d we get pos a 3d vector. How do I fill this value into the appropriate frm structure. I want to follow your advice to fill frame and then write rt_is file from it using the standard methods. The only workaround for a single camera is this dummy correspondence and rewriting of frame structure.

@alexlib
Copy link
Contributor Author

alexlib commented Apr 10, 2018

@yosefm please help me to proceed - creation of sorted_pos is still not the solution as I'll have to use point_position that is basically using ray_tracing that does not have a epi_mm_2D option,

https://github.com/yosefm/pbi/blob/master/ptv/sequence.py#L93

def point_positions(np.ndarray[ndim=3, dtype=pos_t] targets,

double point_position(vec2d targets[], int num_cams, mm_np *multimed_pars,

Maybe I can use some dirty trick by using skew_midpoint twice with the same camera?

double skew_midpoint(vec3d vert1, vec3d direct1, vec3d vert2, vec3d direct2,

@alexlib
Copy link
Contributor Author

alexlib commented Apr 11, 2018

We decided to create a generalized point_positions in orientation.pyx that will include if ... else statement and separate the 3D point_positions case from 2D (single camera case). Before that we also create sorted_pos and sorted_corresp arrays in correspondences.pyx for the single camera case.
Todo:

  1. in correspondences.pyx create a dummy function that creates the structures
  2. create a function in orientation.pyx
  3. expose epi_mm_2d
  4. create single camera test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants