perfectcrop


Nameperfectcrop JSON
Version 1.1.1 PyPI version JSON
download
home_page
SummaryA video cropping tool for artists that detects an object, finds the average center pixel of the bounding box, and crops out from center without a decrease in video quality.
upload_time2024-03-04 05:44:41
maintainer
docs_urlNone
authorRebecca Picanso
requires_python>=3.8,<4.0
license
keywords object detection video
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Perfect Crop

Perfect Crop will locate a detected object within a video clip, find its average location, and create a cropped clip from the center. Object detection models splice videos into individual frames & then run detection on static images - Perfect Crop transmutes this into workable video.

This tool is most useful when used on large clip sets (200+). It was built for the quick processing of over 50 hours of live-stream footage!

As a test example, searching the video for "cell phone":
Source Clip            |  Detected Object
:-------------------------:|:-------------------------:
![](https://github.com/rebeccapicanso/perfect_crop/blob/main/readme_source.gif)| ![](https://github.com/rebeccapicanso/perfect_crop/blob/main/readme_detected.gif)

Perfect Crop's algorithm was built around Hugging Face's [hustvl/yolo](https://www.google.com/search?q=hustvl%2Fyolo-tiny&rlz=1C5CHFA_enUS997US998&oq=yolostiny+hu&gs_lcrp=EgZjaHJvbWUqCggBEAAYChgWGB4yBggAEEUYOTIKCAEQABgKGBYYHjINCAIQABiGAxiABBiKBdIBCDMwNTRqMGo0qAIAsAIA&sourceid=chrome&ie=UTF-8) sets, a series of vision transformer models trained on the [COCO](https://cocodataset.org/#home) dataset. It's computationally light on any system. At the moment, the algorithm is set only for models using YOLO bounding box annotations - so if you want to swap out the model, keep that in mind.

Calculating the center pixel of a bounding box requires backward engineering of detection algorithms - I'm excited to release support for other annotations in v2.

---
Perfect Crop can also label scenes with content and object locations, as well as index a video & splice it into individual scenes without quality loss.

```
perfectcrop accepts the following inputs:

  -p   [video or directory]    | crop a video or directory of clips to select label (runs perfect_crop.py)

  -s   [video]                 | create .json file identifying shots (scene changes) in a long form video. shots.py will then splice the video into individual clips (or scenes).
  
  -vs  [video or directory]    | standardizes video length, codecs, etc. with ffmpeg bash. needed for concatenation!
  
  -g   [video or directory]    | creates a dynamic, randomized moving video grid with ffmpeg bash commands. this is a legacy file from Court Laureate, not necessary for the project itself :)
```

Due to the sensitive nature of working with video, Perfect Crop does not currently support multiple command line options.
Please note that perfectcrop -s needs to be run in the same directory as the source video for shot splicing to occur.

potential errors:
```
  * global loadsave ->   thankfully, this is harmless and most often caused by minute differences in codecs or issues with local reading. I'll hide it.
  * video not found ->   please check permissions, you can do this by running ls -al on the directory & open with chmod commands.
  * file limit hit  ->   grid specific error. please run 'ulimit -n' in terminal to see your current limit, then ulimit -n [whatever] to increase the size to whatever you see fit. please note that this is isolated to your terminal window.
```

---
**Made for Court Laureate, a short film screened at LARPA, December 2023, NY NY.
Although one cannot patent an algorithm, please respect the open-source nature of this project & all derivatives.**



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "perfectcrop",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "object detection,video",
    "author": "Rebecca Picanso",
    "author_email": "rebeccapicansot@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a1/59/c3e2fd6deb1bfc4cd2e0a7dd79cb2a2c211cf70e281a28c893cf91b86b32/perfectcrop-1.1.1.tar.gz",
    "platform": null,
    "description": "# Perfect Crop\n\nPerfect Crop will locate a detected object within a video clip, find its average location, and create a cropped clip from the center. Object detection models splice videos into individual frames & then run detection on static images - Perfect Crop transmutes this into workable video.\n\nThis tool is most useful when used on large clip sets (200+). It was built for the quick processing of over 50 hours of live-stream footage!\n\nAs a test example, searching the video for \"cell phone\":\nSource Clip            |  Detected Object\n:-------------------------:|:-------------------------:\n![](https://github.com/rebeccapicanso/perfect_crop/blob/main/readme_source.gif)| ![](https://github.com/rebeccapicanso/perfect_crop/blob/main/readme_detected.gif)\n\nPerfect Crop's algorithm was built around Hugging Face's [hustvl/yolo](https://www.google.com/search?q=hustvl%2Fyolo-tiny&rlz=1C5CHFA_enUS997US998&oq=yolostiny+hu&gs_lcrp=EgZjaHJvbWUqCggBEAAYChgWGB4yBggAEEUYOTIKCAEQABgKGBYYHjINCAIQABiGAxiABBiKBdIBCDMwNTRqMGo0qAIAsAIA&sourceid=chrome&ie=UTF-8) sets, a series of vision transformer models trained on the [COCO](https://cocodataset.org/#home) dataset. It's computationally light on any system. At the moment, the algorithm is set only for models using YOLO bounding box annotations - so if you want to swap out the model, keep that in mind.\n\nCalculating the center pixel of a bounding box requires backward engineering of detection algorithms - I'm excited to release support for other annotations in v2.\n\n---\nPerfect Crop can also label scenes with content and object locations, as well as index a video & splice it into individual scenes without quality loss.\n\n```\nperfectcrop accepts the following inputs:\n\n  -p   [video or directory]    | crop a video or directory of clips to select label (runs perfect_crop.py)\n\n  -s   [video]                 | create .json file identifying shots (scene changes) in a long form video. shots.py will then splice the video into individual clips (or scenes).\n  \n  -vs  [video or directory]    | standardizes video length, codecs, etc. with ffmpeg bash. needed for concatenation!\n  \n  -g   [video or directory]    | creates a dynamic, randomized moving video grid with ffmpeg bash commands. this is a legacy file from Court Laureate, not necessary for the project itself :)\n```\n\nDue to the sensitive nature of working with video, Perfect Crop does not currently support multiple command line options.\nPlease note that perfectcrop -s needs to be run in the same directory as the source video for shot splicing to occur.\n\npotential errors:\n```\n  * global loadsave ->   thankfully, this is harmless and most often caused by minute differences in codecs or issues with local reading. I'll hide it.\n  * video not found ->   please check permissions, you can do this by running ls -al on the directory & open with chmod commands.\n  * file limit hit  ->   grid specific error. please run 'ulimit -n' in terminal to see your current limit, then ulimit -n [whatever] to increase the size to whatever you see fit. please note that this is isolated to your terminal window.\n```\n\n---\n**Made for Court Laureate, a short film screened at LARPA, December 2023, NY NY.\nAlthough one cannot patent an algorithm, please respect the open-source nature of this project & all derivatives.**\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A video cropping tool for artists that detects an object, finds the average center pixel of the bounding box, and crops out from center without a decrease in video quality.",
    "version": "1.1.1",
    "project_urls": null,
    "split_keywords": [
        "object detection",
        "video"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "255a3c984bc77c84bc26c167e0811ac9a141ed4bc5be14fb41bcff99d2ab1d6c",
                "md5": "6491323499c7b8f81c3c6c72eb35b898",
                "sha256": "bf2b004e4c9005e8e9953e965b746744784b3129ae106fe1af0f528b4629bdcd"
            },
            "downloads": -1,
            "filename": "perfectcrop-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6491323499c7b8f81c3c6c72eb35b898",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 21888,
            "upload_time": "2024-03-04T05:44:39",
            "upload_time_iso_8601": "2024-03-04T05:44:39.300306Z",
            "url": "https://files.pythonhosted.org/packages/25/5a/3c984bc77c84bc26c167e0811ac9a141ed4bc5be14fb41bcff99d2ab1d6c/perfectcrop-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a159c3e2fd6deb1bfc4cd2e0a7dd79cb2a2c211cf70e281a28c893cf91b86b32",
                "md5": "5427ebf88a505b5917477716dbec9326",
                "sha256": "3946be17babde08087ff7f27d25e81188a07f50b4d0edb7da6ecf9ba90c7b0a6"
            },
            "downloads": -1,
            "filename": "perfectcrop-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5427ebf88a505b5917477716dbec9326",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 21274,
            "upload_time": "2024-03-04T05:44:41",
            "upload_time_iso_8601": "2024-03-04T05:44:41.129100Z",
            "url": "https://files.pythonhosted.org/packages/a1/59/c3e2fd6deb1bfc4cd2e0a7dd79cb2a2c211cf70e281a28c893cf91b86b32/perfectcrop-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-04 05:44:41",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "perfectcrop"
}
        
Elapsed time: 0.20795s