Made based on CUDA 9 installation
Download CUDA https://developer.nvidia.com/cuda-downloads Run commands:
sudo dpkg -i cuda-repo-<version>.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
| # This script does a perspective transformation with an A4 paper | |
| # Get an A4 sheet, put it on a table in front of your webcam | |
| # just close enough so that all its corners are visible. | |
| # Run this script, you will be given a frame from the webcam. | |
| # Pick the corners of the A4 sheet for the software, by double clicking on its corners | |
| # one by one in the following order: top left, top right, bottom left, bottom right. | |
| # Just as you select the last corner, a live feed without the perspective distortion | |
| # shows up and now you can write something on it, and have a view of it as if | |
| # the camera was right on top of it. Cheers! | |
| # visit: |
| '''This script goes along the blog post | |
| "Building powerful image classification models using very little data" | |
| from blog.keras.io. | |
| It uses data that can be downloaded at: | |
| https://www.kaggle.com/c/dogs-vs-cats/data | |
| In our setup, we: | |
| - created a data/ folder | |
| - created train/ and validation/ subfolders inside data/ | |
| - created cats/ and dogs/ subfolders inside train/ and validation/ | |
| - put the cat pictures index 0-999 in data/train/cats |
| ''' | |
| Using OpenCV takes a mp4 video and produces a number of images. | |
| Requirements | |
| ---- | |
| You require OpenCV 3.2 to be installed. | |
| Run | |
| ---- | |
| Open the main.py and edit the path to the video. Then run: |
Made based on CUDA 9 installation
Download CUDA https://developer.nvidia.com/cuda-downloads Run commands:
sudo dpkg -i cuda-repo-<version>.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
| import cv2 | |
| import io | |
| import socket | |
| import struct | |
| import time | |
| import pickle | |
| import zlib | |
| client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| client_socket.connect(('192.168.1.124', 8485)) |
| # Create video writer | |
| writer = cv2.VideoWriter("sample_output.avi", | |
| cv2.VideoWriter_fourcc(*"MJPG"), | |
| 30,(1800,480)) | |
| for frame in tqdm(merged_maps): | |
| writer.write(frame.astype('uint8')) | |
| writer.release() |
| %Official Matlab version can be found in the PASCAL VOC devkit | |
| %http://host.robots.ox.ac.uk/pascal/VOC/voc2012/index.html#devkit | |
| % VOCLABELCOLORMAP Creates a label color map such that adjacent indices have different | |
| % colors. Useful for reading and writing index images which contain large indices, | |
| % by encoding them as RGB images. | |
| % | |
| % CMAP = VOCLABELCOLORMAP(N) creates a label color map with N entries. | |
| function cmap = labelcolormap(N) |
This script reads PascalVOC xml files, and converts them to YOLO txt files.
Note: This script was written and tested on Ubuntu. YMMV on other OS's.
Disclaimer: This code is a modified version of Joseph Redmon's voc_label.py
| import cv2 | |
| import os | |
| import numpy as np | |
| from PIL import Image, ImageFont, ImageDraw | |
| from typing import Tuple, Optional, Union, List | |
| from dataclasses import dataclass, InitVar | |
| import sys | |
| from pathlib import Path | |
| from enum import Enum | |
| import logging |