virtucamera.VCBase Viewport Methods - shycats/PyVirtuCamera GitHub Wiki


capture_will_start( vcserver )
This method is called whenever a client app requests a video
feed from the viewport. Usefull to init a pixel buffer
or other objects you may need to capture the viewport

IMPORTANT! Calling vcserver.set_capture_resolution() and
vcserver.set_capture_mode() here is a must. Please check
the documentation for those methods.

You can also call vcserver.set_vertical_flip() here optionally,
if you need to flip your pixel buffer. Disabled by default.

Parameters
----------
vcserver : virtucamera.VCServer object
    Instance of virtucamera.VCServer calling this method.

Related: VCServer.set_capture_resolution() ||| VCServer.set_capture_mode() ||| VCServer.set_vertical_flip()

capture_did_end( vcserver )
Optional, this method is called whenever a client app
stops the viewport video feed. Usefull to destroy a pixel buffer
or other objects you may have created to capture the viewport.

Parameters
----------
vcserver : virtucamera.VCServer object
    Instance of virtucamera.VCServer calling this method.
get_capture_coords( vcserver, camera_name )
If vcserver.capture_mode == vcserver.CAPMODE_SCREENSHOT, it must
return a tuple or list with the left-top coordinates (x,y)
of the screen region to be captured, being 'x' the horizontal axis
and 'y' the vertical axis. If you don't use CAPMODE_SCREENSHOT,
you don't need to overload this method.

If the screen region has changed in size from the previous call to
this method, and therefore the capture resolution is different,
vcserver.set_capture_resolution() must be called here before returning.
You can use vcserver.capture_width and vcserver.capture_height
to check the previous resolution.

The name of the camera selected in the app is provided,
as can be usefull to set-up the viewport render in some cases.

Parameters
----------
vcserver : virtucamera.VCServer object
    Instance of virtucamera.VCServer calling this method.
camera_name : str
    Name of the camera that is currently selected in the App.

Returns
-------
tuple or list of 2 float
    left-top screen coordinates of the capture region as (x,y).

Related: VCServer.set_capture_mode() ||| VCServer.capture_mode ||| VCServer.set_capture_resolution()

get_capture_buffer( vcserver, camera_name )
If vcserver.capture_mode == vcserver.CAPMODE_BUFFER, it must
return a contiguous buffer as a Python bytes-like object
implementing the 'Buffer Protocol', containing raw pixels of
the viewport image. If you don't use CAPMODE_BUFFER,
you don't need to overload this method.

If the capture resolution has changed in size from the previous call to
this method, vcserver.set_capture_resolution() must be called here
before returning. You can use vcserver.capture_width and
vcserver.capture_height to check the previous resolution.

The name of the camera selected in the app is provided,
as can be usefull to set-up the viewport render in some cases.

Parameters
----------
vcserver : virtucamera.VCServer object
    Instance of virtucamera.VCServer calling this method.
camera_name : str
    Name of the camera that is currently selected in the App.

Returns
-------
object - Buffer protocol
    raw pixels of the viewport image as a contiguous Python buffer

Related: VCServer.set_capture_mode() ||| VCServer.capture_mode ||| VCServer.set_capture_resolution()

get_capture_pointer( vcserver, camera_name )
If vcserver.capture_mode == vcserver.CAPMODE_BUFFER_POINTER,
it must return an int representing a memory address to the first
element of a contiguous buffer containing raw pixels of the 
viewport image. The buffer must be kept allocated untill the next
call to this function, is your responsability to do so.
If you don't use CAPMODE_BUFFER_POINTER
you don't need to overload this method.

If the capture resolution has changed in size from the previous call to
this method, vcserver.set_capture_resolution() must be called here
before returning. You can use vcserver.capture_width and
vcserver.capture_height to check the previous resolution.

The name of the camera selected in the app is provided,
as can be usefull to set-up the viewport render in some cases.

Parameters
----------
vcserver : virtucamera.VCServer object
    Instance of virtucamera.VCServer calling this method.
camera_name : str
    Name of the camera that is currently selected in the App.

Returns
-------
int
    value of the memory address to the first element of the buffer.

Related: VCServer.set_capture_mode() ||| VCServer.capture_mode ||| VCServer.set_capture_resolution()

look_through_camera( vcserver, camera_name )
This method must set the viewport to look through
the specified camera.

Parameters
----------
vcserver : virtucamera.VCServer object
    Instance of virtucamera.VCServer calling this method.
camera_name : str
    Name of the camera to look through