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

Rename picture => image. #587

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions adapters/gst/gst_plugins/python/media_files_src_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

MIME_TYPE_REGEX = {
FileType.VIDEO: re.compile(r'video/.*'),
FileType.PICTURE: re.compile(r'image/(jpeg|png)'),
FileType.IMAGE: re.compile(r'image/(jpeg|png)'),
}

SIZE_MB = 2**20
Expand All @@ -42,7 +42,7 @@ class MediaFilesSrcBin(LoggerMixin, Gst.Bin):
'file-type': (
GObject.TYPE_STRING,
'File type',
'Type of media files to read ("video" or "picture")',
'Type of media files to read ("video" or "image")',
None,
GObject.ParamFlags.READWRITE,
),
Expand All @@ -57,7 +57,7 @@ class MediaFilesSrcBin(LoggerMixin, Gst.Bin):
'framerate': (
str,
'Framerate',
'Framerate for pictures. Used only when file-type=picture.',
'Framerate for images. Used only when file-type=image.',
DEFAULT_FRAMERATE,
GObject.ParamFlags.READWRITE,
),
Expand Down Expand Up @@ -139,7 +139,7 @@ def do_set_state(self, state: Gst.State):
if self.current_state == Gst.State.NULL and state != Gst.State.NULL:
self.validate_properties()

if self.file_type == FileType.PICTURE:
if self.file_type == FileType.IMAGE:
self.src_pad.add_probe(Gst.PadProbeType.BUFFER, self.set_frame_duration)

# TODO: check file type for HTTP location
Expand Down Expand Up @@ -342,7 +342,7 @@ def attach_parser(self, pad: Gst.Pad, caps: Gst.Caps):
filtered_caps = Gst.Caps.from_string(codec.value.caps_with_params)
self.capsfilter.set_property('caps', filtered_caps)
modified_caps = Gst.Caps.from_string(filtered_caps[0].get_name())
if self.file_type == FileType.PICTURE:
if self.file_type == FileType.IMAGE:
# jpegparse allows only framerate=1/1
# pngparse doesn't set framerate
modified_caps.set_value(
Expand Down
2 changes: 1 addition & 1 deletion adapters/gst/sources/media_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [[ -n "${RECEIVE_TIMEOUT_MSECS}" ]]; then
else
RECEIVE_TIMEOUT="receive-timeout=5000"
fi
if [[ "${FILE_TYPE}" == "picture" ]]; then
if [[ "${FILE_TYPE}" == "image" ]]; then
MEASURE_PER_FILE=false
EOS_ON_FILE_END="${EOS_ON_FILE_END:="false"}"
else
Expand Down
8 changes: 4 additions & 4 deletions docs/source/savant_101/10_adapters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ The images are served from:

**Parameters**:

- ``FILE_TYPE``: a flag specifying that the adapter is used for images; it must always be set to ``picture``;
- ``FILE_TYPE``: a flag specifying that the adapter is used for images; it must always be set to ``image``;
- ``LOCATION``: a filesystem location (path or directory) or HTTP URL from where images are served;
- ``FRAMERATE``: a desired framerate for the output video stream generated from image files (the parameter is used only if ``SYNC_OUTPUT=True``);
- ``SYNC_OUTPUT``: a flag indicating that images are delivered into a module as a video stream; otherwise, the files are sent as fast as the module is capable processing them; default is ``False``;
Expand All @@ -280,9 +280,9 @@ Running the adapter with Docker:

.. code-block:: bash

docker run --rm -it --name source-pictures-files-test \
docker run --rm -it --name images-source \
--entrypoint /opt/savant/adapters/gst/sources/media_files.sh \
-e FILE_TYPE=picture \
-e FILE_TYPE=image \
-e ZMQ_ENDPOINT=dealer+connect:ipc:///tmp/zmq-sockets/input-video.ipc \
-e SOURCE_ID=test \
-e LOCATION=/path/to/images \
Expand All @@ -295,7 +295,7 @@ Running with the helper script:

.. code-block:: bash

./scripts/run_source.py pictures --source-id=test /path/to/images
./scripts/run_source.py images --source-id=test /path/to/images

Video File Source Adapter
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- ZMQ_ENDPOINT=req+connect:ipc:///tmp/zmq-sockets/input.ipc
- SOURCE_ID=coco-images
- LOCATION=/data
- FILE_TYPE=picture
- FILE_TYPE=image
entrypoint: /opt/savant/adapters/gst/sources/media_files.sh
depends_on:
module:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- ZMQ_ENDPOINT=req+connect:ipc:///tmp/zmq-sockets/input.ipc
- SOURCE_ID=coco-images
- LOCATION=/data
- FILE_TYPE=picture
- FILE_TYPE=image
entrypoint: /opt/savant/adapters/gst/sources/media_files.sh
depends_on:
module:
Expand Down
4 changes: 2 additions & 2 deletions savant/utils/file_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class FileType(Enum):
VIDEO = 'video'
PICTURE = 'picture'
IMAGE = 'image'

@staticmethod
def from_mime_type(mime_type: Optional[str]) -> Optional['FileType']:
Expand All @@ -15,7 +15,7 @@ def from_mime_type(mime_type: Optional[str]) -> Optional['FileType']:
if mime_type.startswith('video/'):
return FileType.VIDEO
if mime_type.startswith('image/'):
return FileType.PICTURE
return FileType.IMAGE


def parse_mime_types(files: List[Path]) -> List[Tuple[Path, str]]:
Expand Down
12 changes: 6 additions & 6 deletions scripts/run_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def files_source(
extra_volumes: List[str] = None,
detach: bool = False,
):
"""Read picture or video files from LOCATION.
"""Read image or video files from LOCATION.
LOCATION can be single file, directory or HTTP URL.
"""
if location.startswith('http://') or location.startswith('https://'):
Expand Down Expand Up @@ -383,11 +383,11 @@ def multi_stream_source(
)


@cli.command('pictures')
@cli.command('images')
@click.option(
'--framerate',
default='30/1',
help='Frame rate of the pictures.',
help='Frame rate of the images.',
show_default=True,
)
@click.option(
Expand All @@ -413,7 +413,7 @@ def multi_stream_source(
@sync_option
@adapter_docker_image_option('gstreamer')
@click.argument('location', required=True)
def pictures_source(
def images_source(
source_id: str,
out_endpoint: str,
out_type: str,
Expand All @@ -429,7 +429,7 @@ def pictures_source(
read_metadata: bool,
eos_on_file_end: bool,
):
"""Read picture files from LOCATION.
"""Read image files from LOCATION.
LOCATION can be single file, directory or HTTP URL.
"""

Expand All @@ -444,7 +444,7 @@ def pictures_source(
fps_period_seconds=fps_period_seconds,
fps_output=fps_output,
location=location,
file_type='picture',
file_type='image',
envs=[
f'FRAMERATE={framerate}',
f'SORT_BY_TIME={sort_by_time}',
Expand Down
4 changes: 2 additions & 2 deletions scripts/uri-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def run_source(

\b
URI can be:
- path to a single file (video or picture);
- HTTP(S) URL to a single file (video or picture);
- path to a single file (video or image);
- HTTP(S) URL to a single file (video or image);
- path to video device (e.g. /dev/video0);
- RTSP URL.

Expand Down