https://github.com/developer239/simple-color-batch-cropper
Automatically crops positive/negative samples for your haar cascades. Example uses images from Swords and Souls web game. You can also use this library to mark your images.
https://github.com/developer239/simple-color-batch-cropper
Last synced: about 1 year ago
JSON representation
Automatically crops positive/negative samples for your haar cascades. Example uses images from Swords and Souls web game. You can also use this library to mark your images.
- Host: GitHub
- URL: https://github.com/developer239/simple-color-batch-cropper
- Owner: developer239
- Created: 2018-01-06T20:30:51.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-04T17:47:27.000Z (about 8 years ago)
- Last Synced: 2025-01-04T21:41:42.835Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 2.78 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.MD
Awesome Lists containing this project
README
# Simple Color Batch cropper
### Installation
```
$ yarn install
```
Make sure to have OpenCV 3+ (extra modules are optional) installed on your system https://github.com/opencv/opencv/releases/.
More information can be found here: [opencv4nodejs](https://github.com/justadudewhohacks/opencv4nodejs#how-to-install)
### What does it do
#### Positive images
1) When you need to generate large amount of positive samples of all _shooting targets_ automatically

2) This script will generate binary image

3) Then it will find all shooting targets for you

4) Then it will draw bounding box around all targets

#### Negative images
`src/negative.js` will crop random locations from the original image so that none of the locations contain matches that you found using the `src/positive.js` file. This is useful when you want to generate large number of negative samples.
### How to use
* Put image that you want to process in `src/images` folder
* Create config variables in `src/config` folder. Every obect that you want to crop has its own config file. For example config for cropping apples:
```
export const UPPER_COLOR = new Vec(200, 65, 255) // Upper color range !! IMPORTANT
export const LOWER_COLOR = new Vec(10, 10, 130) // Lower color range !! IMPORTANT
export const BLUR = 5 // Necessary for removing noise from image !! IMPORTANT
export const OFFSET = -50 // Top/left for positive image preview
export const REGION_SIZE = 100 // Positive image preview size
export const PATH = './src/images/withAppleSmall.jpg' // Path to image that will be parsed
```
* Import correct config in `src/positive.js` and `src/negative.js` files
* Run either `yarn positive` or `yarn negative` in order to see the result