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

Extend API to support stereo streams #18

Closed
dzhoshkun opened this issue Oct 16, 2018 · 12 comments
Closed

Extend API to support stereo streams #18

dzhoshkun opened this issue Oct 16, 2018 · 12 comments
Assignees

Comments

@dzhoshkun
Copy link
Contributor

With #5 GIFT-Grab will support stereo video stream capture from BlackMagic devices. When extending the API, among others, the implications on encoding should be considered.

Encoding is currently done by IVideoTarget implementors that expose only an append method (in addition to the update method inherited from IObserver). However both methods take only a VideoFrame as a parameter. Would it be good for instance to add an optional VideoFrame parameter to these methods? This has the advantage that VideoFrame stays as it is (=dumb, simple).

Another option is to extend VideoFrame itself. Possible design patterns are pointed out here: #5 (comment) Some initial thoughts as well: #5 (comment), #5 (comment) This however does not sound like a good option any more, as it changes VideoFrame's and its clients' interfaces.

@dzhoshkun
Copy link
Contributor Author

The discussion with @cbergeles and his team on 23 Oct 2018 has revealed that a video frame should be as tightly coupled to its stereo frame as possible.
This is because stereo frames are hardware-synchronised, and as such if for instance they get encoded into two different video files, the sync information will essentially be lost.

@dzhoshkun
Copy link
Contributor Author

@cbergeles
Copy link

I watched the video, or parts of it, and I can't recommend pursuing this. It seems a bit esoteric... I've never heard of the library before, and personally I would not use it over OpenCV (with which most people have experience!). Just my 2 cents :)

@dzhoshkun dzhoshkun self-assigned this Oct 29, 2018
@dzhoshkun
Copy link
Contributor Author

@cbergeles Thanks! The particular interesting bit of GIL in this case is the pixel iterator. This with the aim of providing NumPy-like "views" on e.g. a video frame's stereo frame. Tom and I were looking into this, considering whether it could help extend the API in a minimally invasive way.

@dzhoshkun
Copy link
Contributor Author

Re: OpenCV

I agree it's a great toolkit. And GIFT-Grab currently uses it for a number of tasks. However in the particular case of GIFT-Grab it's an overkill to ask the user to install OpenCV to be able to use GIFT-Grab. Using OpenCV merely for capturing and encoding video streams is a bit like driving a Ferrari in the countryside :) So we are in the process of removing the dependency on OpenCV (see #9).

@tvercaut
Copy link
Member

tvercaut commented Nov 1, 2018

Re Boost GIL, I agree it is a bit esoteric and probably a bit of an overkill as well but as @dzhoshkun mentioned, some of its underpinning concepts could help us support stereo in an elegant and easy manner.

We could offer a slightly different interface in python and c++ to make use of the most adequate tool for this in each language. For example, if a stereo image is provided in memory as a left+right concatenated together, depending on the exact memory layout, we could create a numpy view on the underlying array to show only the left or the right image by using adequate (very long) stride/padding:
https://www.numpy.org/devdocs/reference/generated/numpy.lib.stride_tricks.as_strided.html

OpenCV also support the notion of steps but I haven't looked at this in detail:
https://docs.opencv.org/master/d3/d63/classcv_1_1Mat.html

@dzhoshkun
Copy link
Contributor Author

dzhoshkun commented Nov 13, 2018

Idea:

  • an optional stereo_count parameter for the init_from_specs() method
  • and its corresponding getter as well!
  • possibly an analogue of the above for this VideoFrame constructor
  • an optional stereo_index parameter for the data() method
  • in this configuration the data_length() method will report the length of a single frame, or the length of a specific frame by virtue of a similar optional index parameter

@dzhoshkun
Copy link
Contributor Author

dzhoshkun commented Nov 13, 2018

  • extend the video frame NumPy compatibility tests to accommodate new interface as well

dzhoshkun added a commit that referenced this issue Nov 14, 2018
dzhoshkun added a commit that referenced this issue Nov 15, 2018
@dzhoshkun
Copy link
Contributor Author

dzhoshkun added a commit that referenced this issue Nov 19, 2018
dzhoshkun added a commit that referenced this issue Nov 19, 2018
@dzhoshkun
Copy link
Contributor Author

dzhoshkun commented Nov 19, 2018

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

3 participants