An open API service indexing awesome lists of open source software.

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.

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
![1](https://github.com/developer239/simple-color-batch-cropper/blob/master/documentation/images/1.png?raw=true)
2) This script will generate binary image
![2](https://github.com/developer239/simple-color-batch-cropper/blob/master/documentation/images/2.png?raw=true)
3) Then it will find all shooting targets for you
![3](https://github.com/developer239/simple-color-batch-cropper/blob/master/documentation/images/3.png?raw=true)
4) Then it will draw bounding box around all targets
![4](https://github.com/developer239/simple-color-batch-cropper/blob/master/documentation/images/4.png?raw=true)

#### 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