-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .frame import VideoFrame | ||
from .stream import VideoStream | ||
from . import display |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from av.sidedata.sidedata import SideData | ||
|
||
def get_display_rotation(matrix: SideData) -> float: | ||
"""Extract the rotation component of the `DISPLAYMATRIX` transformation matrix. | ||
Args: | ||
matrix (SideData): The transformation matrix. | ||
Returns: | ||
float: The angle (in degrees) by which the transformation rotates the frame | ||
counterclockwise. The angle will be in range [-180.0, 180.0]. | ||
Note: | ||
Floating point numbers are inherently inexact, so callers are | ||
recommended to round the return value to the nearest integer before use. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cimport libav as lib | ||
from libc.stdint cimport int32_t | ||
|
||
import numpy as np | ||
|
||
from av.sidedata.sidedata import SideData | ||
from av.sidedata.sidedata import Type as SideDataType | ||
|
||
|
||
def get_display_rotation(matrix): | ||
if not isinstance(matrix, SideData) or matrix.type != SideDataType.DISPLAYMATRIX: | ||
raise ValueError("Matrix must be `SideData` of type `DISPLAYMATRIX`") | ||
cdef const int32_t[:] view = np.frombuffer(matrix, dtype=np.int32) | ||
if view.shape[0] != 9: | ||
raise ValueError("Matrix must be 3x3 represented as a 9-element array") | ||
return lib.av_display_rotation_get(&view[0]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters