Skip to content

Instantly share code, notes, and snippets.

@git-hamza
git-hamza / two_camera_sync_frame.py
Created June 13, 2023 12:50
Get synchronize frames based on different FPS
video_1_path = "1.mp4"
video_2_path = "2.mp4"
paths = [video_1_path, video_2_path]
vid_caps = {idx+1: cv2.VideoCapture(path_) for idx, path_ in enumerate(paths)}
tracebar_video = 1
tracebar_frame = 15000
@git-hamza
git-hamza / google_videointelligence_logorecognition_output_visualizer.py
Created May 16, 2023 07:27
Draw google video intelligence logo recognition annotate a local video output
"""
Annotate a video in Cloud Storage provides you an option to generate the output as json.
This script can be used you annotate a local video (https://cloud.google.com/video-intelligence/docs/logo-recognition#annotate_a_local_video).
This script will help to generate the bounding box per frame and also draw it on the video.
"""
import io
import json
from google.cloud import videointelligence
@git-hamza
git-hamza / yolov5_format_dataset_class_based_statistics.py
Created April 17, 2023 11:19
class/label based statistics in horizental bar chart to visualize the data distribution for yolov5 format dataset
import yaml
import os
import matplotlib.pyplot as plt
# Define paths to image and label directories, and class YAML file
data_dirs = ["train", "valid", "test"]
class_yaml_path = "data.yaml"
# Load class names from YAML file
with open(class_yaml_path, 'r') as f:
@git-hamza
git-hamza / Jupyter_notebook_from_remote_docker.md
Last active March 21, 2022 13:25
Accessing Jupyter notebook locally from docker hosted in remote server

SSH to the remote server:

Open cmd/terminal and connect the local port to the remote server port. ssh -L 127.0.0.1:3000:0.0.0.0:1234 USER@IP

Start the docker container inside the remote server:

For starting the docker, make sure to keep the port same as provided above. An example of starting a docker is given below. docker run -it -p 1234:8888 IMAGENAME /bin/bash

Run Jupyter Notebook:

Now that you have run the above command with /bin/bash, it will take you inside the docker container. Make sure to have jupyter notebook installed in there. Run the following command inside the docker container terminal.