agrimgupta92 / sgan

Code for "Social GAN: Socially Acceptable Trajectories with Generative Adversarial Networks", Gupta et al, CVPR 2018
MIT License
819 stars 260 forks source link

Transformation meters to pixels UCY for collision checking #5

Closed tessavdheiden closed 6 years ago

tessavdheiden commented 6 years ago

Hi Agrim,

Currently I am checking the number of collisions with the static environment (trees, benches, snow).

For the ETH dataset I have a proper transformation (Homography). The same method does not work for the UCY data. Do you have your conversion script (from pixels to meters) to generate input data?

Best

agrimgupta92 commented 6 years ago

This snippet might be helpful to you. Please note this is an approximation.

import cv2
pts_img = np.array([[476, 117], [562, 117], [562, 311],[476, 311]])
pts_wrd = np.array([[0, 0], [1.81, 0], [1.81, 4.63],[0, 4.63]])
h, status = cv2.findHomography(pts_img, pts_wrd)
tessavdheiden commented 6 years ago

Hi Agrim,

Thanks for the code snippit. Is there any chance you can send me the whole code for converting the UCY data to meters? I spend a whole day reverse engineering, without success.

Do you want to see my code?

agrimgupta92 commented 6 years ago

The snippet gives you the homography matrix to convert from pixels to real world coordinates. That should be sufficient for what you are trying to achieve.

zhangpur commented 5 years ago

Hi Agrim, I'm confused with the frame index of the provided data, which is indexed begin with zero, while the data download from the website(ETH) is indexed begin with one. And there is a little gap between the coordinates value. Is it produced by manually interpolation? What's the interpolation policy?

agrimgupta92 commented 5 years ago

I used scipy.interpolate.interp1d for interpolation. Also, as mentioned in the paper we convert all the data to real world coordinates and interpolate to obtain values at every 0.4 seconds. We provide the data so that people can use the same dataset for uniform comparison across algorithms.

zhangpur commented 5 years ago

Thanks for reply! By the way, I think the ETH(univ) dataset is prefer to be 0.4s every 6 frame rather than 10 frame. Because the pedestrian in the video are walking obviously faster than the normal, in addition, the former setting is more similar to the description in the original paper(You will never walk alone:...(ICCV2009)), which said the dataset is more than 25 minutes long(the video of hotel is 13 minutes), while the video from the website is only 8 minutes long. Just for suggesting.

trungmanhhuynh commented 5 years ago

Start index with 0 could be wrong a bit. When you visualize it, do you plot data with index 0 in frame 1 ? However, the data of frame 1 is already available in gt file, so why dont you start with index 1 for better accuracy ?

trungmanhhuynh commented 5 years ago

@agrimgupta92 I would like to ask about crowds dataset you used, in crowds_ucy there are lots of people (more than 20 i can count) in school yard, but your data in univ_example.txt only has ~6,7 people (at frame 3170 for example). frame 0 is only 1, while there should be a lot (~30). Below is your data at frame 3170) 3170.0 46.0 0.862906949465 10.5921992309 3170.0 47.0 1.42800576881 11.1816889362 3170.0 48.0 1.79526738511 11.9473095737 3170.0 49.0 13.3798984142 8.12636618024 3170.0 50.0 3.85887778498 8.48793577681 3170.0 51.0 10.4232845542 7.14189450642 3170.0 52.0 2.156004583 12.5878724761

could you please correct me if i am reading the wrong file? I want to visualize the ground truth trajectories on frame images. If you are able to publish your pre-processing code, it would be so perfect for us the achieve and believe in the uniform data. Please help ! Thanks.

@tessavdheiden @zhangpur Are you able to get correct data and how it is compared to data in this work?

trungmanhhuynh commented 5 years ago

I think i was looking at the wrong file. it should be students003.txt instead of univ_example.txt. Still, I dont know what the file univ_example.txt and students001.txt are.

trungmanhhuynh commented 5 years ago

Hi @agrimgupta92, Sorry for raising too many concerns, but I wish I can visualize the ground truth trajectory on images.

I was able to have correct trajectory (in pixels) by pre-process data from *vsp files given by crowds dataset. However, when I used the snippet code you provided above, I could not have the same location in meters (compared to you data).

By running the code you gave, i obtained h = 0.0210 0 -10.0180 0 0.0230 -2.7900 0 0 1.0000

Then, I picked one target in crowds_ucy dataset at frame 0 , target id = 409, the pixel location is (537,386). I can make sure my pixel location is correct because I did visualize it. You can find in your data file (student003.txt), this target has location (11.3019763869, 4.53453619456)

However, if I use h, and pixel locations to convert it to meter location using the formula: h*[386, 537, 1]',

I got [1.259, 16.4380] is the location in meter. It is different with your data ((11.3019763869, 4.53453619456).

Could you please help me on this ? Anyone has any ideas what I did wrong please help. I just want to know the correct transformation between pixels and meters so that can clear my thoughts.

108618026 commented 1 year ago

The snippet gives you the homography matrix to convert from pixels to real world coordinates. That should be sufficient for what you are trying to achieve.

Hello @agrimgupta92, Could you give me a hint on how to convert from pixels to real world coordinates on the custom dataset? Thanks in advanced.