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

About video-gaze mapping procedure #4

Open
ajdroid opened this issue May 1, 2020 · 1 comment
Open

About video-gaze mapping procedure #4

ajdroid opened this issue May 1, 2020 · 1 comment

Comments

@ajdroid
Copy link

ajdroid commented May 1, 2020

In video.py, the VideoFramesAndMappedGaze does sync in this way:

T = self.__df__.index[self.__df__.index.get_loc(self.__current_time__+self.__i__, method='nearest')]

As I understand it, current_time is the current frame's ts and you are finding the nearest ts in the gaze data.
Here, why is the i counter being added to current_time?

@ajdroid
Copy link
Author

ajdroid commented May 2, 2020

I think one way to solve this would be (keep current time in the vts timeline and convert to tsusing the latest offset when retrieving the gaze for each video frame):

class VideoFramesAndMappedGaze:

    def __init__(self, gazedata, videoCapture, fps):
        self.__cap__ = videoCapture
        if (self.__cap__.isOpened() == False):
            print("Error opening video stream or file")
            raise IOError
        self.__current_frameAndMappedGaze__ = None
        self.__df__ = gazedata.toDataFrame()
        self.__vts__ = gazedata.getVTS()
        self.__vts_list__ = self.__vts__.values()
        self.__ts_list__ = self.__vts__.keys()
        self.__frame_duration__ = int(1000/fps)
        self.__current_time__ = self.__vts_list__[0]
        self.__i__ = 0
        self.__offset__ = self.__ts_list__[0] - self.__vts_list__[0]

    def __iter__(self):
        return self

    def __next__(self):
        if (self.__cap__.isOpened()):
            ret, frame = self.__cap__.read()
            if ret == True:
                if self.__current_time__ > self.__vts_list__[self.__i__]:
                    if self.__i__ < len(self.__vts_list__) - 1:
                        self.__i__ += 1
                        self.__offset__ = self.__ts_list__[self.__i__] \
                                 - self.__vts_list__[self.__i__]
                T = self.__df__.index[self.__df__.index.get_loc(self.__current_time__\
                    + self.__offset__, method='nearest')]
                x = self.__df__.at[T, GazeData.GazePixelX]
                y = self.__df__.at[T, GazeData.GazePixelY]
            else:
                raise StopIteration
            self.__current_time__ += self.__frame_duration__
            return (frame, x, y, T)
        else:
            raise StopIteration

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

1 participant