diff --git a/.gitignore b/.gitignore
index 4500ccd..77cfcf2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ node_modules/
/icons
/src/icons/svgs/*.svg
.tmp-output-remote-icons
+_tmp-output-remote-icons
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f218314..eb1e7e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,35 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+
+# [2.2.0](https://github.com/equinusocio/vsc-material-theme/compare/v2.0.1...v2.2.0) (2018-06-28)
+
+
+### Bug Fixes
+
+* Fix rust file icon association ([c4e1dbe](https://github.com/equinusocio/vsc-material-theme/commit/c4e1dbe))
+* Fix some icon colors and add haxe file icon ([04e7db8](https://github.com/equinusocio/vsc-material-theme/commit/04e7db8))
+* **Icons:** Add icon to .spec.ts files ([fad5e29](https://github.com/equinusocio/vsc-material-theme/commit/fad5e29))
+* **Lighter:** Fix folders icon association ([b2c8be8](https://github.com/equinusocio/vsc-material-theme/commit/b2c8be8))
+* Fix statubar item hover background ([c19ab43](https://github.com/equinusocio/vsc-material-theme/commit/c19ab43))
+* Fix status bar hover item background on Lighter variant. ([27624fa](https://github.com/equinusocio/vsc-material-theme/commit/27624fa))
+* Fix terminal.ansiBlack color ([86def00](https://github.com/equinusocio/vsc-material-theme/commit/86def00)), closes [#180](https://github.com/equinusocio/vsc-material-theme/issues/180)
+* Fix titlebar contrast color ([74e0456](https://github.com/equinusocio/vsc-material-theme/commit/74e0456))
+* Fix ts icon color ([4c851ea](https://github.com/equinusocio/vsc-material-theme/commit/4c851ea)), closes [#172](https://github.com/equinusocio/vsc-material-theme/issues/172)
+* Improve panels titles ([905e99a](https://github.com/equinusocio/vsc-material-theme/commit/905e99a)), closes [#208](https://github.com/equinusocio/vsc-material-theme/issues/208)
+
+
+### Features
+
+* Add .lnk file icon ([8aaabe8](https://github.com/equinusocio/vsc-material-theme/commit/8aaabe8)), closes [#201](https://github.com/equinusocio/vsc-material-theme/issues/201)
+* Add mdx file icon ([d191329](https://github.com/equinusocio/vsc-material-theme/commit/d191329)), closes [#211](https://github.com/equinusocio/vsc-material-theme/issues/211)
+* Add support to the new settings view ([1e6150b](https://github.com/equinusocio/vsc-material-theme/commit/1e6150b))
+* New command to enabling/disabling icons auto-applaying ([0fa2ac0](https://github.com/equinusocio/vsc-material-theme/commit/0fa2ac0))
+* New redesigned icons for folders and add new scs and css folder icon ([a293a6f](https://github.com/equinusocio/vsc-material-theme/commit/a293a6f))
+* New set of file icons with new and redesigned icons ([eb1c2ed](https://github.com/equinusocio/vsc-material-theme/commit/eb1c2ed))
+
+
+
# [2.1.0](https://github.com/equinusocio/vsc-material-theme/compare/v2.0.1...v2.1.0) (2018-05-24)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 3e296f9..3d9fc68 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,13 +4,12 @@
## Requirements:
-* Nodejs ^6.x
+* Nodejs ^8.x
* Visual Studio Code
* GPG Tool
- [Contributing guidelines](#contributing-guidelines)
- [Requirements:](#requirements)
- - [Decrypt content](#decrypt-content)
- [Installing and compiling source](#installing-and-compiling-source)
- [Testing the theme](#testing-the-theme)
- [Adding new Material Theme commands](#adding-new-material-theme-commands)
@@ -21,16 +20,6 @@
- [Backers](#backers)
- [Sponsors](#sponsors)
-## Decrypt content
-We use git-crypt to encrypt compiler files. To contribute you need a GPG key public/private associated with your github email.
-
-1. Export your public key by running
-
-```gpg --output PATH/FILENAME.gpg --export ASSOCIATEDEMAIL```
-
-2. Send the exported `.gpg` file to a contributor that will add you to the trusted people.
-3. Fetch and pull then decrypt files with `git-crypt unlock` entering your key password.
-
## Installing and compiling source
First you will have to install node_modules through npm or yarn
@@ -43,7 +32,7 @@ yarn install
To compile to the source code, you have to execute the build task through visual studio code.
First you need to invoke to quick command (on MacOS `โP`, while on Linux/windows is `ctrl+p`)
-then type `task build` and wait until vsc will have finished the task.
+then type `task build` and wait until VSC will have finished the task.
### Testing the theme
@@ -51,6 +40,82 @@ To test the theme, you will have to go to the debug section, select the *Launch
### Adding new Material Theme commands
+Material Theme commands are located inside the `extensions/commands` directory. They are split by folders so you can find a single specific `index.ts` file inside a `command` folder. This is a patter choice: so you can add related command helpers inside that folder.
+
+#### index.ts
+
+The main file must return a `function`. The `function` can be `async` or `sync`.
+
+We want to make this clear, so the `async` declaration must be present even if you want to use `then()` for chaining inside the `function`.
+
+##### Example of `async` exported `function`
+
+```js
+export default async (): Promise => {
+
+ ...
+```
+
+##### Example of `sync` exported `function`
+
+```js
+export default (): boolean => {
+
+ ...
+```
+
+#### Using external "mini" modules
+
+We encourage you to split up your command in other small modules so they can be **tested** more easily and outside of the context.
+
+#### Register the command
+
+You must register the new command to execute it when it's called by the user.
+
+Firstly add the command to our commands `extensions/commands/index.ts`
+
+```js
+export {default as awesomeCommand} from './awesome-command';
+```
+
+Commands are registered within the `extensions/material.theme.config.ts` file.
+
+Just add a new registration after the others that will run your command:
+
+```js
+
+ Commands.registerCommand('materialTheme.awesomeCommand', () => ThemeCommands.awesomeCommand());
+
+```
+
+#### Add to package.json
+
+When you are ready to test your new command you must add its declaration within the `package.json`. The command **must be prefixed with** `materialTheme.` prefix.
+
+As the others your command will look like this:
+
+Level: `contribute.commands -> Array`
+```json
+
+ {
+ "command": "materialTheme.awesomeCommand",
+ "title": "Awesome Title For Command",
+ "category": "๐จ Material Theme"
+ }
+
+```
+
+#### Build and run
+
+Now you can re-build the theme and just run the debug, you will see your command in the command list of VSCode just searching for its title.
+
+#### Test your command
+
+A test suite is currently in developing. Update soon.
+
+
+### Adding new custom setting
+
Soon(ish)ยฎ
### Adding new icons
@@ -59,10 +124,12 @@ Soon(ish)ยฎ
* Add the reference to that icon to the `~/src/icons/partials/fileNames.js` or if your icon is referred to a directory adds the reference to the `~/src/icons/partials/folderNames.js` file, otherwise to `~/src/icons/partials/fileExtensions.js` if is referred to a file extension.
-* If you want to make the icon sensitive to be accented, modify the `~/extensions/defaults.json` file, adding the icon definition to the `accentableIcons` array (e.g. ["_folder_open", "_folder_open_build"]) and the path to the `icons.theme.iconDefinitions` object. The same applies to variants (the variant icons array is called "variantsIcons")
+* If you want to make the icon sensitive to be accented, modify the `~/extensions/defaults.json` file, adding the icon definition to the `accentableIcons` array (e.g. ["_folder_open", "_folder_open_build"]) and the path to the `icons.theme.iconDefinitions` object. **The same applies to variants (the variant icons array is called "variantsIcons")**
* Execute the build command.
+* Start the debug
+
* Enjoy your new icons in Material Theme, and don't forget to pull request!
diff --git a/README.md b/README.md
index 265f439..5311db5 100644
--- a/README.md
+++ b/README.md
@@ -4,14 +4,11 @@
[![Twitter](https://img.shields.io/twitter/url/https/github.com/equinusocio/vsc-material-theme.svg?style=flat-square)](https://twitter.com/intent/tweet?text=This%20is%20the%20most%20epic%20theme:&url=https%3A%2F%2Fgithub.com%2Fequinusocio%2Fvsc-material-theme)
[![GitHub tag](https://img.shields.io/github/release/equinusocio/vsc-material-theme.svg?style=flat-square)](https://github.com/equinusocio/vsc-material-theme/releases)
-
+
The most epic theme meets Visual Studio Code. You can help by reporting issues [here](https://github.com/equinusocio/vsc-material-theme/issues)
-
-
- [Getting started](#getting-started)
- [Installation](#installation)
- [Packaged VSIX Extension](#packaged-vsix-extension)
@@ -19,10 +16,9 @@ The most epic theme meets Visual Studio Code. You can help by reporting issues [
- [Activate theme](#activate-theme)
- [Fix File Icons](#fix-file-icons)
- [Set the accent color](#set-the-accent-color)
- - [Disabling/enabling file icons auto-applying](#disabling-enabling-file-icons-auto-applying)
+ - [Disabling/enabling file icons auto-applying](#disablingenabling-file-icons-auto-applying)
- [Override theme colors](#override-theme-colors)
- [Color Scheme override](#color-scheme-override)
- - [UI Overrides](#ui-overrides)
- [Recommended settings for a better experience](#recommended-settings-for-a-better-experience)
- [Official Portings](#official-portings)
- [Other resources](#other-resources)
@@ -30,7 +26,6 @@ The most epic theme meets Visual Studio Code. You can help by reporting issues [
- [Backers](#backers)
- [Sponsors](#sponsors)
-
# Getting started
@@ -138,6 +133,7 @@ You can override the material theme ui and schemes colors by adding these theme-
```js
"editor.tokenColorCustomizations": {
"[Material Theme VARIANT]": {
+ "sideBar.background": "#347890",
"textMateRules": [
{
"scope": [
@@ -155,16 +151,6 @@ You can override the material theme ui and schemes colors by adding these theme-
},
```
-### UI Overrides
-
-```js
-"workbench.colorCustomizations": {
- "[Material Theme]": {
- "sideBar.background": "#347890"
- },
-}
-```
-
# Recommended settings for a better experience
```js
diff --git a/extensions/commands/accents-setter/index.ts b/extensions/commands/accents-setter/index.ts
index 263367c..0f65c32 100644
--- a/extensions/commands/accents-setter/index.ts
+++ b/extensions/commands/accents-setter/index.ts
@@ -1,77 +1,19 @@
import * as vscode from 'vscode';
-import {IAccentCustomProperty} from './../../interfaces/iaccent-custom-property';
-import {IGenericObject} from './../../interfaces/igeneric-object';
-import {
- updateAccent,
-} from './../../helpers/settings';
-import {getDefaultValues} from './../../helpers/fs';
+import {updateAccent} from './../../helpers/settings';
+import {getDefaultValues, getAccentsProperties} from './../../helpers/fs';
const REGEXP_HEX: RegExp = /^#([0-9A-F]{6}|[0-9A-F]{8})$/i;
-const accentsProperties: IGenericObject = {
- 'activityBarBadge.background': {
- alpha: 100,
- value: undefined
- },
- 'list.activeSelectionForeground': {
- alpha: 100,
- value: undefined
- },
- 'list.inactiveSelectionForeground': {
- alpha: 100,
- value: undefined
- },
- 'list.highlightForeground': {
- alpha: 100,
- value: undefined
- },
- 'scrollbarSlider.activeBackground': {
- alpha: 50,
- value: undefined
- },
- 'editorSuggestWidget.highlightForeground': {
- alpha: 100,
- value: undefined
- },
- 'textLink.foreground': {
- alpha: 100,
- value: undefined
- },
- 'progressBar.background': {
- alpha: 100,
- value: undefined
- },
- 'pickerGroup.foreground': {
- alpha: 100,
- value: undefined
- },
- 'tab.activeBorder': {
- alpha: 100,
- value: undefined
- },
- 'notificationLink.foreground': {
- alpha: 100,
- value: undefined
- },
- 'editor.findWidgetResizeBorder': {
- alpha: 100,
- value: undefined
- },
- 'editorWidget.border': {
- alpha: 100,
- value: undefined
- }
-};
-
/**
* Assigns colours
*/
const assignColorCustomizations = (colour: string, config: any): void => {
+ const accentsProperties = getAccentsProperties();
const newColour = isValidColour(colour) ? colour : undefined;
Object.keys(accentsProperties).forEach(propertyName => {
- const accent: IAccentCustomProperty = accentsProperties[propertyName];
+ const accent = accentsProperties[propertyName];
let colorProp = newColour;
if (colour && accent.alpha < 100) {
@@ -110,7 +52,7 @@ export default async (): Promise => {
const accentSelected = await vscode.window.showQuickPick(options);
if (accentSelected === null || accentSelected === undefined) {
- Promise.resolve(null);
+ return Promise.resolve(null);
}
const config: any = vscode.workspace.getConfiguration().get('workbench.colorCustomizations');
diff --git a/extensions/defaults.json b/extensions/defaults.json
index 78a94b5..29bd12f 100644
--- a/extensions/defaults.json
+++ b/extensions/defaults.json
@@ -25,6 +25,8 @@
"_folder_node_open",
"_folder_images_open",
"_folder_js_open",
+ "_folder_css_open",
+ "_folder_sass_open",
"_folder_src_open",
"_folder_assets_open",
"_folder_bower_open",
@@ -34,12 +36,86 @@
"_folder_dist_open",
"_folder_ci_open"
],
+ "accentsProperties": {
+ "activityBarBadge.background": {
+ "alpha": 100,
+ "value": null
+ },
+ "list.activeSelectionForeground": {
+ "alpha": 100,
+ "value": null
+ },
+ "list.inactiveSelectionForeground": {
+ "alpha": 100,
+ "value": null
+ },
+ "list.highlightForeground": {
+ "alpha": 100,
+ "value": null
+ },
+ "scrollbarSlider.activeBackground": {
+ "alpha": 50,
+ "value": null
+ },
+ "editorSuggestWidget.highlightForeground": {
+ "alpha": 100,
+ "value": null
+ },
+ "textLink.foreground": {
+ "alpha": 100,
+ "value": null
+ },
+ "progressBar.background": {
+ "alpha": 100,
+ "value": null
+ },
+ "pickerGroup.foreground": {
+ "alpha": 100,
+ "value": null
+ },
+ "tab.activeBorder": {
+ "alpha": 100,
+ "value": null
+ },
+ "notificationLink.foreground": {
+ "alpha": 100,
+ "value": null
+ },
+ "editor.findWidgetResizeBorder": {
+ "alpha": 100,
+ "value": null
+ },
+ "editorWidget.border": {
+ "alpha": 100,
+ "value": null
+ },
+ "settings.modifiedItemForeground": {
+ "alpha": 100,
+ "value": null
+ },
+ "panelTitle.activeBorder": {
+ "alpha": 100,
+ "value": null
+ }
+ },
"changelog": {
"lastversion": "2.1.0"
},
"icons": {
"theme": {
"iconDefinitions": {
+ "_folder_sass": {
+ "iconPath": "../icons/folder_sass.svg"
+ },
+ "_folder_sass_open": {
+ "iconPath": "../icons/folder_sass_open.svg"
+ },
+ "_folder_css": {
+ "iconPath": "../icons/folder_css.svg"
+ },
+ "_folder_css_open": {
+ "iconPath": "../icons/folder_css_open.svg"
+ },
"_folder_ci": {
"iconPath": "../icons/folder_ci.svg"
},
@@ -121,15 +197,9 @@
"_folder_dark": {
"iconPath": "../icons/folder_dark.svg"
},
- "_folder_dark_build": {
- "iconPath": "../icons/folder_dark_build.svg"
- },
"_folder_light": {
"iconPath": "../icons/folder_light.svg"
},
- "_folder_light_build": {
- "iconPath": "../icons/folder_light_build.svg"
- },
"_file_folder": {
"iconPath": "../icons/file_folder.svg"
},
@@ -188,22 +258,22 @@
"Ocean High Contrast": "vs-dark"
},
"variantsIcons": [
- "_folder_dark_build",
- "_folder_dark",
- "_folder_light_build",
- "_folder_light",
- "_folder_vscode",
+ "_folder_sass",
+ "_folder_css",
+ "_folder_ci",
+ "_folder_dist",
+ "_folder_test",
+ "_folder_github",
+ "_folder_git",
+ "_folder_bower",
+ "_folder_assets",
+ "_folder_src",
+ "_folder_js",
+ "_folder_images",
"_folder_gulp",
"_folder_node",
- "_folder_images",
- "_folder_js",
- "_folder_src",
- "_folder_assets",
- "_folder_bower",
- "_folder_git",
- "_folder_github",
- "_folder_test",
- "_folder_dist",
- "_folder_ci"
+ "_folder_vscode",
+ "_folder_dark",
+ "_folder_light"
]
}
\ No newline at end of file
diff --git a/extensions/helpers/fs.ts b/extensions/helpers/fs.ts
index 688baea..9dca63b 100644
--- a/extensions/helpers/fs.ts
+++ b/extensions/helpers/fs.ts
@@ -36,6 +36,10 @@ export function getVariantIcons(): string[] {
return getDefaultValues().variantsIcons;
}
+export function getAccentsProperties() {
+ return getDefaultValues().accentsProperties;
+}
+
/**
* Gets a theme content by a given contribute ID
*/
diff --git a/extensions/helpers/messages.ts b/extensions/helpers/messages.ts
index a33a2af..1d60dd1 100644
--- a/extensions/helpers/messages.ts
+++ b/extensions/helpers/messages.ts
@@ -4,11 +4,22 @@ import {
import * as ThemeCommands from './../commands';
-const INFO_MESSAGE = 'You should reload the window for full activate the Material Theme.';
-const OPTIONS = {ok: 'Reload now', cancel: 'Cancel'};
+const MESSAGES = {
+ INFO: {
+ message: 'You should reload the window for full activate the Material Theme.',
+ options: {ok: 'Reload now', cancel: 'Cancel'}
+ },
+ CHANGELOG: {
+ message: 'Material Theme was updated. Check the changelog for more details!',
+ options: {ok: 'Show changelog', cancel: 'Maybe later'}
+ }
+};
export const infoMessage = async () => {
- if (await Window.showInformationMessage(INFO_MESSAGE, OPTIONS.ok, OPTIONS.cancel) === OPTIONS.ok) {
+ if (await Window.showInformationMessage(MESSAGES.INFO.message, MESSAGES.INFO.options.ok, MESSAGES.INFO.options.cancel) === MESSAGES.INFO.options.ok) {
ThemeCommands.fixIcons();
}
};
+
+export const changelogMessage = async () =>
+ await Window.showInformationMessage(MESSAGES.CHANGELOG.message, MESSAGES.CHANGELOG.options.ok, MESSAGES.CHANGELOG.options.cancel) === MESSAGES.CHANGELOG.options.ok;
diff --git a/extensions/interfaces/idefaults.ts b/extensions/interfaces/idefaults.ts
index 799799e..3301e5a 100644
--- a/extensions/interfaces/idefaults.ts
+++ b/extensions/interfaces/idefaults.ts
@@ -1,5 +1,9 @@
+import {IGenericObject} from './igeneric-object';
+import {IAccentCustomProperty} from './iaccent-custom-property';
+
export interface IDefaults {
accents: IAccents;
+ accentsProperties: IGenericObject ;
accentableIcons: string[];
changelog: IChangelog;
icons: IDefaultsThemeIcons;
diff --git a/extensions/material.theme.config.ts b/extensions/material.theme.config.ts
index 8466755..e3086e9 100644
--- a/extensions/material.theme.config.ts
+++ b/extensions/material.theme.config.ts
@@ -6,10 +6,10 @@ import {
import * as ThemeCommands from './commands';
import {isAutoApplyEnable} from './helpers/settings';
import {onChangeConfiguration} from './helpers/configuration-change';
-import {infoMessage} from './helpers/messages';
+import {infoMessage, changelogMessage} from './helpers/messages';
import shouldShowChangelog from './helpers/should-show-changelog';
-export function activate() {
+export async function activate() {
const config = Workspace.getConfiguration();
// Listen on set theme: when the theme is Material Theme, just adjust icon and accent.
@@ -21,7 +21,10 @@ export function activate() {
}
if (shouldShowChangelog()) {
- ThemeCommands.showChangelog();
+ const show = await changelogMessage();
+ if (show) {
+ ThemeCommands.showChangelog();
+ }
}
// Registering commands
diff --git a/package.json b/package.json
index 8f6bf4f..e885ab2 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "vsc-material-theme",
"displayName": "Material Theme",
"description": "The most epic theme now for Visual Studio Code",
- "version": "2.1.0",
+ "version": "2.2.0",
"publisher": "Equinusocio",
"license": "Apache-2.0",
"author": "Mattia Astorino [@equinusocio]",
@@ -28,7 +28,7 @@
}
},
"scripts": {
- "build": "yarn get-remote-icons && yarn build-icons && yarn build-themes && yarn build-icons-accents && yarn build-icons-variants && yarn build-icons-variants-json",
+ "build": "rimraf _tmp-output-remote-icons/ && yarn get-remote-icons && yarn build-icons && yarn build-themes && yarn build-icons-accents && yarn build-icons-variants && yarn build-icons-variants-json",
"minimize-icons": "mkdir icons && svgo -f src/icons/svgs -o icons/",
"minimize-json": "json-minify themes/.material-theme-icons.tmp > themes/Material-Theme-Icons.json && yarn remove-icons-tmp",
"remove-icons": "rimraf icons && rimraf themes/Material-Theme-Icons.json",
@@ -214,7 +214,6 @@
"json-minify": "1.0.0",
"mustache": "2.3.0",
"ncp": "2.0.0",
- "rimraf": "2.6.2",
"run-sequence": "2.2.1",
"standard-version": "4.3.0",
"svgo": "1.0.4",
diff --git a/src/icons/partials/fileExtensions.js b/src/icons/partials/fileExtensions.js
index d6b1c4d..7873616 100644
--- a/src/icons/partials/fileExtensions.js
+++ b/src/icons/partials/fileExtensions.js
@@ -1,4 +1,6 @@
"fileExtensions": {
+ "mdx": "_file_mdx",
+ "lnk": "_file_lnk",
"pm": "_file_perl",
"pl": "_file_perl",
"sql": "_file_sql",
@@ -39,6 +41,9 @@
"css": "_file_css",
"postcss": "_file_postcss",
"pcss": "_file_postcss",
+ "postcssrc": "_file_postcss",
+ "postcss.config.js": "_file_postcss",
+ "postcssrc.js": "_file_postcss",
"scss": "_file_sass",
"sass": "_file_sass",
"less": "_file_less",
@@ -139,6 +144,8 @@
"cpp": "_file_cpp",
"c++": "_file_cpp",
"hpp": "_file_cpp",
+ "hxx": "_file_cpp",
+ "hh": "_file_cpp",
"mm": "_file_cpp",
"cxx": "_file_cpp",
"go": "_file_go",
diff --git a/src/icons/partials/fileNames.js b/src/icons/partials/fileNames.js
index 8ec6f55..814445a 100644
--- a/src/icons/partials/fileNames.js
+++ b/src/icons/partials/fileNames.js
@@ -1,10 +1,10 @@
"fileNames": {
- ".prettierrc": "_file_prettier",
"prettier.config.js": "_file_prettier",
".prettierrc.js": "_file_prettier",
".prettierrc.json": "_file_prettier",
".prettierrc.yaml": "_file_prettier",
".prettierrc.yml": "_file_prettier",
+ ".prettierrc": "_file_prettier",
".prettierignore": "_file_prettier",
"code_of_conduct.md": "_file_conduct",
"jest.config.js": "_file_jest",
diff --git a/src/icons/partials/folderNames.js b/src/icons/partials/folderNames.js
index b6b9f4a..61c0706 100644
--- a/src/icons/partials/folderNames.js
+++ b/src/icons/partials/folderNames.js
@@ -5,13 +5,18 @@
"assets": "_folder_assets",
"bower_components": "_folder_bower",
"js": "_folder_js",
+ "css": "_folder_css",
+ "style": "_folder_style",
+ "sass": "_folder_sass",
+ "scss": "_folder_sass",
"src": "_folder_src",
"images": "_folder_images",
".git": "_folder_git",
".github": "_folder_github",
".vscode": "_folder_vscode",
".gulp": "_folder_gulp",
- "build": "_folder_dark_build",
+ "gulp": "_folder_gulp",
+ "build": "_folder_dark_dist",
"dist": "_folder_dist"
},
"folderNamesExpanded": {
@@ -23,10 +28,14 @@
"src": "_folder_src_open",
"images": "_folder_images_open",
"js": "_folder_js_open",
+ "css": "_folder_css_open",
+ "style": "_folder_css_open",
+ "sass": "_folder_sass_open",
+ "scss": "_folder_scss_open",
".git": "_folder_git_open",
".github": "_folder_github_open",
".gulp": "_folder_gulp_open",
".vscode": "_folder_vscode_open",
- "build": "_folder_open_build",
+ "build": "_folder_open_dist",
"dist": "_folder_dist_open"
-}
\ No newline at end of file
+}
diff --git a/src/themes/settings/specific/darker-hc.json b/src/themes/settings/specific/darker-hc.json
index f8c3e08..120a3f9 100644
--- a/src/themes/settings/specific/darker-hc.json
+++ b/src/themes/settings/specific/darker-hc.json
@@ -26,6 +26,7 @@
"statusbarForeground": "#616161",
"listHoverForeground": "#FFFFFF",
"tabActiveForeground": "#FFFFFF",
+ "inactiveSelectionBackground": "#00000030",
"base": {
"white": "#ffffff",
"black": "#000000",
diff --git a/src/themes/settings/specific/darker.json b/src/themes/settings/specific/darker.json
index 9bb7181..7c1e6c9 100644
--- a/src/themes/settings/specific/darker.json
+++ b/src/themes/settings/specific/darker.json
@@ -28,6 +28,7 @@
"listHoverForeground": "#FFFFFF",
"listHoverBackground": "#212121",
"tabActiveForeground": "#FFFFFF",
+ "inactiveSelectionBackground": "#00000030",
"base": {
"white": "#ffffff",
"black": "#000000",
diff --git a/src/themes/settings/specific/default-hc.json b/src/themes/settings/specific/default-hc.json
index d3035ea..013fae0 100644
--- a/src/themes/settings/specific/default-hc.json
+++ b/src/themes/settings/specific/default-hc.json
@@ -28,6 +28,7 @@
"listHoverForeground": "#FFFFFF",
"listHoverBackground": "#263238",
"tabActiveForeground": "#FFFFFF",
+ "inactiveSelectionBackground": "#00000030",
"base": {
"white": "#ffffff",
"black": "#000000",
diff --git a/src/themes/settings/specific/default.json b/src/themes/settings/specific/default.json
index 9042608..cee0445 100644
--- a/src/themes/settings/specific/default.json
+++ b/src/themes/settings/specific/default.json
@@ -28,6 +28,7 @@
"listHoverForeground": "#FFFFFF",
"listHoverBackground": "#263238",
"tabActiveForeground": "#FFFFFF",
+ "inactiveSelectionBackground": "#00000030",
"base": {
"white": "#ffffff",
"black": "#000000",
diff --git a/src/themes/settings/specific/lighter-hc.json b/src/themes/settings/specific/lighter-hc.json
index 9788c97..09e31c4 100644
--- a/src/themes/settings/specific/lighter-hc.json
+++ b/src/themes/settings/specific/lighter-hc.json
@@ -8,7 +8,7 @@
"contrastBorder": "#CBCBCB",
"scrollbars": "#00000040",
"sidebarForeground": "#627883",
- "comments": "#90A4AE90",
+ "comments": "#90A4AE",
"caret": "#272727",
"findHighlight": "#FFCC00",
"foreground": "#90A4AE",
@@ -28,6 +28,7 @@
"listHoverForeground": "#B1C7D3",
"listHoverBackground": "#FAFAFA",
"tabActiveForeground": "#000000",
+ "inactiveSelectionBackground": "#CCD7DA50",
"base": {
"white": "#FFFFFF",
"black": "#000000",
diff --git a/src/themes/settings/specific/lighter.json b/src/themes/settings/specific/lighter.json
index 6ccfff2..0e694dc 100644
--- a/src/themes/settings/specific/lighter.json
+++ b/src/themes/settings/specific/lighter.json
@@ -6,7 +6,7 @@
"background": "#FAFAFA",
"backgroundAlt": "#FAFAFA",
"contrastBorder": "#FAFAFA",
- "comments": "#90A4AE90",
+ "comments": "#90A4AE",
"caret": "#272727",
"findHighlight": "#FFCC00",
"foreground": "#90A4AE",
@@ -28,6 +28,7 @@
"listHoverForeground": "#B1C7D3",
"listHoverBackground": "#FAFAFA",
"tabActiveForeground": "#000000",
+ "inactiveSelectionBackground": "#CCD7DA50",
"base": {
"white": "#FFFFFF",
"black": "#000000",
diff --git a/src/themes/settings/specific/ocean-hc.json b/src/themes/settings/specific/ocean-hc.json
index 068caf0..cb47930 100644
--- a/src/themes/settings/specific/ocean-hc.json
+++ b/src/themes/settings/specific/ocean-hc.json
@@ -28,6 +28,7 @@
"listHoverForeground": "#FFFFFF",
"listHoverBackground": "#292D3E",
"tabActiveForeground": "#FFFFFF",
+ "inactiveSelectionBackground": "#00000030",
"base": {
"white": "#ffffff",
"black": "#000000",
diff --git a/src/themes/settings/specific/ocean.json b/src/themes/settings/specific/ocean.json
index afe91d3..522bf0d 100644
--- a/src/themes/settings/specific/ocean.json
+++ b/src/themes/settings/specific/ocean.json
@@ -28,6 +28,7 @@
"listHoverForeground": "#FFFFFF",
"listHoverBackground": "#292D3E",
"tabActiveForeground": "#FFFFFF",
+ "inactiveSelectionBackground": "#00000030",
"base": {
"white": "#ffffff",
"black": "#000000",
diff --git a/src/themes/settings/specific/palenight-hc.json b/src/themes/settings/specific/palenight-hc.json
index 72d3922..5a99295 100644
--- a/src/themes/settings/specific/palenight-hc.json
+++ b/src/themes/settings/specific/palenight-hc.json
@@ -28,6 +28,7 @@
"listHoverForeground": "#FFFFFF",
"listHoverBackground": "#292D3E",
"tabActiveForeground": "#FFFFFF",
+ "inactiveSelectionBackground": "#00000030",
"base": {
"white": "#ffffff",
"black": "#000000",
diff --git a/src/themes/settings/specific/palenight.json b/src/themes/settings/specific/palenight.json
index f60b56c..867a080 100644
--- a/src/themes/settings/specific/palenight.json
+++ b/src/themes/settings/specific/palenight.json
@@ -28,6 +28,7 @@
"listHoverForeground": "#FFFFFF",
"listHoverBackground": "#292D3E",
"tabActiveForeground": "#FFFFFF",
+ "inactiveSelectionBackground": "#00000030",
"base": {
"white": "#ffffff",
"black": "#000000",
diff --git a/src/themes/theme-template-color-theme.json b/src/themes/theme-template-color-theme.json
index 337d6c2..80a4f45 100644
--- a/src/themes/theme-template-color-theme.json
+++ b/src/themes/theme-template-color-theme.json
@@ -756,7 +756,7 @@
"list.activeSelectionBackground": "{{variant.scheme.backgroundAlt}}",
"list.activeSelectionForeground": "{{commons.accents.Teal}}",
"list.inactiveSelectionForeground": "{{commons.accents.Teal}}",
- "list.inactiveSelectionBackground": "#00000030",
+ "list.inactiveSelectionBackground": "{{variant.scheme.inactiveSelectionBackground}}",
"list.focusBackground": "{{variant.scheme.foreground}}20",
"list.focusForeground": "{{variant.scheme.foreground}}",
"list.highlightForeground": "{{commons.accents.Teal}}",
@@ -787,13 +787,16 @@
"editorError.foreground": "{{variant.scheme.base.red}}70",
"editorWarning.foreground": "{{variant.scheme.base.green}}70",
"editorWidget.background": "{{variant.scheme.backgroundAlt}}",
- "editor.findWidgetResizeBorder": "{{commons.accents.Teal}}",
+ "editorWidget.resizeBorder": "{{commons.accents.Teal}}",
"editorWidget.border": "{{variant.scheme.base.Teal}}",
"editorMarkerNavigation.background": "{{variant.scheme.foreground}}05",
"widget.shadow": "{{variant.scheme.shadow}}",
"panel.border": "{{variant.scheme.contrastBorder}}60",
"panel.background": "{{variant.scheme.backgroundAlt}}",
- "panelTitle.activeForeground": "{{variant.scheme.foreground}}",
+ "panel.dropBackground": "{{variant.scheme.foreground}}",
+ "panelTitle.inactiveForeground": "{{variant.scheme.foreground}}",
+ "panelTitle.activeForeground": "{{variant.scheme.tabActiveForeground}}",
+ "panelTitle.activeBorder": "{{commons.accents.Teal}}",
"diffEditor.insertedTextBackground": "{{variant.scheme.base.green}}15",
"diffEditor.removedTextBackground": "{{variant.scheme.base.red}}20",
"notifications.background": "{{variant.scheme.background}}",
@@ -819,6 +822,7 @@
"gitDecoration.modifiedResourceForeground": "{{variant.scheme.base.blue}}90",
"gitDecoration.untrackedResourceForeground": "{{variant.scheme.base.green}}90",
"gitDecoration.ignoredResourceForeground": "{{variant.scheme.sidebarForeground}}90",
- "peekViewResult.selectionBackground": "{{variant.scheme.sidebarForeground}}70"
+ "peekViewResult.selectionBackground": "{{variant.scheme.sidebarForeground}}70",
+ "settings.modifiedItemForeground": "{{commons.accents.Teal}}"
}
}
diff --git a/test/--.tmcolor b/test/--.tmcolor
deleted file mode 100644
index 885b2b2..0000000
--- a/test/--.tmcolor
+++ /dev/null
@@ -1,79 +0,0 @@
-comment โ for comments.
-comment.line โ line comments, we specialize further so that the type of comment start character(s) can be extracted from the scope.
-comment.line.double-slash โ // comment
-comment.line.double-dash โ -- comment
-comment.line.number-sign โ # comment
-comment.line.percentage โ % comment
-comment.line.character โ other types of line comments.
-comment.block โ multi-line comments like /* โฆ */ and .
-comment.block.documentation โ embedded documentation.
-
-constant โ various forms of constants.
-constant.numeric โ those which represent numbers, e.g. 42, 1.3f, 0x4AB1U.
-constant.character โ those which represent characters, e.g. <, \e, \031.
-constant.escape โ escape sequences like \e would be constant.character.escape.
-constant.language โ constants (generally) provided by the language which are โspecialโ like true, false, nil, YES, NO, etc.
-constant.other โ other constants, e.g. colors in CSS.
-
-entity โ an entity refers to a larger part of the document, for example a chapter, class, function, or tag. We do not scope the entire entity as entity.* (we use meta.* for that). But we do use entity.* for the โplaceholdersโ in the larger entity, e.g. if the entity is a chapter, we would use entity.name.section for the chapter title.
-entity.name โ we are naming the larger entity.
-entity.name.function โ the name of a function.
-entity.name.type โ the name of a type declaration or class.
-entity.name.tag โ a tag name.
-entity.name.section โ the name is the name of a section/heading.
-entity.other โ other entities.
-entity.other.inherited-class โ the superclass/baseclass name.
-entity.other.attribute-name โ the name of an attribute (mainly in tags).
-
-invalid โ stuff which is โinvalidโ.
-invalid.illegal โ illegal, e.g. an ampersand or lower-than character in HTML (which is not part of an entity/tag).
-invalid.deprecated โ for deprecated stuff e.g. using an API function which is deprecated or using styling with strict HTML.
-
-keyword โ keywords (when these do not fall into the other groups).
-keyword.control โ mainly related to flow control like continue, while, return, etc.
-keyword.operator โ operators can either be textual (e.g. or) or be characters.
-keyword.other โ other keywords.
-
-markup โ this is for markup languages and generally applies to larger subsets of the text.
-markup.underline โ underlined text.
-markup.underline.link โ this is for links, as a convenience this is derived from markup.underline so that if there is no theme rule which specifically targets markup.underline.link then it will inherit the underline style.
-markup.bold โ bold text (text which is strong and similar should preferably be derived from this name).
-markup.heading โ a section header. Optionally provide the heading level as the next element, for example markup.heading.2.html for โฆ
in HTML.
-markup.italic โ italic text (text which is emphasized and similar should preferably be derived from this name).
-markup.list โ list items.
-markup.list.numbered โ numbered list items.
-markup.list.unnumbered โ unnumbered list items.
-markup.quote โ quoted (sometimes block quoted) text.
-markup.raw โ text which is verbatim, e.g. code listings. Normally spell checking is disabled for markup.raw.
-markup.inline.raw
-markup.other โ other markup constructs.
-
-meta - the meta scope is generally used to markup larger parts of the document. For example the entire line which declares a function would be meta.function and the subsets would be storage.type, entity.name.function, variable.parameter etc. and only the latter would be styled. Sometimes the meta part of the scope will be used only to limit the more general element that is styled, most of the time meta scopes are however used in scope selectors for activation of bundle items. For example in Objective-C there is a meta scope for the interface declaration of a class and the implementation, allowing the same tab-triggers to expand differently, depending on context.
-
-storage โ things relating to โstorageโ.
-storage.type โ the type of something, class, function, int, var, etc.
-storage.modifier โ a storage modifier like static, final, abstract, etc.
-
-string โ strings.
-string.quoted โ quoted strings.
-string.quoted.single โ single quoted strings: 'foo'.
-string.quoted.double โ double quoted strings: "foo".
-string.quoted.triple โ triple quoted strings: """Python""".
-string.quoted.other โ other types of quoting: $'shell', %s{...}.
-string.unquoted โ for things like here-docs and here-strings.
-string.interpolated โ strings which are โevaluatedโ: `date`, $(pwd).
-string.regexp โ regular expressions: /(\w+)/.
-string.other โ other types of strings (should rarely be used).
-
-support โ things provided by a framework or library should be below support.
-support.function โ functions provided by the framework/library. For example NSLog in Objective-C is support.function.
-support.class โ when the framework/library provides classes.
-support.type โ types provided by the framework/library, this is probably only used for languages derived from C, which has typedef (and struct). Most other languages would introduce new types as classes.
-support.constant โ constants (magic values) provided by the framework/library.
-support.variable โ variables provided by the framework/library. For example NSApp in AppKit.
-support.other โ the above should be exhaustive, but for everything else use support.other.
-
-variable โ variables. Not all languages allow easy identification (and thus markup) of these.
-variable.parameter โ when the variable is declared as the parameter.
-variable.language โ reserved language variables like this, super, self, etc.
-variable.other โ other variables, like $some_variables.
diff --git a/test/.gitignore b/test/.gitignore
deleted file mode 100755
index e69de29..0000000
diff --git a/test/Dockerfile b/test/Dockerfile
deleted file mode 100644
index e69de29..0000000
diff --git a/test/LICENSE b/test/LICENSE
deleted file mode 100644
index e69de29..0000000
diff --git a/test/Procfile b/test/Procfile
deleted file mode 100644
index e69de29..0000000
diff --git a/test/TODO b/test/TODO
deleted file mode 100644
index e69de29..0000000
diff --git a/test/adobe.ai b/test/adobe.ai
deleted file mode 100644
index e69de29..0000000
diff --git a/test/adobe.as b/test/adobe.as
deleted file mode 100644
index e69de29..0000000
diff --git a/test/adobe.cfc b/test/adobe.cfc
deleted file mode 100644
index e69de29..0000000
diff --git a/test/adobe.cfm b/test/adobe.cfm
deleted file mode 100644
index e69de29..0000000
diff --git a/test/adobe.pdf b/test/adobe.pdf
deleted file mode 100644
index e69de29..0000000
diff --git a/test/adobe.psb b/test/adobe.psb
deleted file mode 100644
index e69de29..0000000
diff --git a/test/adobe.psd b/test/adobe.psd
deleted file mode 100644
index e69de29..0000000
diff --git a/test/angular.ng.html b/test/angular.ng.html
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.7z b/test/archive.7z
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.7zip b/test/archive.7zip
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.gz b/test/archive.gz
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.pzip b/test/archive.pzip
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.rar b/test/archive.rar
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.tar b/test/archive.tar
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.tgz b/test/archive.tgz
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.wim b/test/archive.wim
deleted file mode 100644
index e69de29..0000000
diff --git a/test/archive.zip b/test/archive.zip
deleted file mode 100644
index e69de29..0000000
diff --git a/test/audio.mp3 b/test/audio.mp3
deleted file mode 100644
index 8b13789..0000000
--- a/test/audio.mp3
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/test/audio.wma b/test/audio.wma
deleted file mode 100644
index e69de29..0000000
diff --git a/test/binary.tga b/test/binary.tga
deleted file mode 100644
index e69de29..0000000
diff --git a/test/bower.json b/test/bower.json
deleted file mode 100644
index e69de29..0000000
diff --git a/test/component.ts b/test/component.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/test/font.eot b/test/font.eot
deleted file mode 100644
index e69de29..0000000
diff --git a/test/font.otf b/test/font.otf
deleted file mode 100644
index e69de29..0000000
diff --git a/test/font.ttf b/test/font.ttf
deleted file mode 100644
index e69de29..0000000
diff --git a/test/font.woff b/test/font.woff
deleted file mode 100644
index e69de29..0000000
diff --git a/test/image.jpg b/test/image.jpg
deleted file mode 100644
index e69de29..0000000
diff --git a/test/image.svg b/test/image.svg
deleted file mode 100644
index e69de29..0000000
diff --git a/test/package-lock.json b/test/package-lock.json
deleted file mode 100644
index e69de29..0000000
diff --git a/test/package.json b/test/package.json
deleted file mode 100644
index e69de29..0000000
diff --git a/test/settings.ini b/test/settings.ini
deleted file mode 100644
index e69de29..0000000
diff --git a/test/shell.bash b/test/shell.bash
deleted file mode 100644
index 957abd2..0000000
--- a/test/shell.bash
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-echo "$RANDOM" # Supported in bash. No warnings.
diff --git a/test/shell.fish b/test/shell.fish
deleted file mode 100644
index e69de29..0000000
diff --git a/test/shell.sh b/test/shell.sh
deleted file mode 100644
index b3d23a0..0000000
--- a/test/shell.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-echo "$RANDOM" # Unsupported in sh. Produces warning.
diff --git a/test/sketch.sketch b/test/sketch.sketch
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.applescript b/test/source.applescript
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.asa b/test/source.asa
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.ascx b/test/source.ascx
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.asp b/test/source.asp
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.aspx b/test/source.aspx
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.blade b/test/source.blade
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.blade.php b/test/source.blade.php
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.c b/test/source.c
deleted file mode 100644
index 644923c..0000000
--- a/test/source.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "ccv.h"
-#include "ccv_internal.h"
-#include
-#ifdef HAVE_GSL
-#include
-#include
-#endif
-#ifdef USE_OPENMP
-#include
-#endif
-
-const ccv_bbf_param_t ccv_bbf_default_params = {
- .interval = 5,
- .min_neighbors = 2,
- .accurate = 1,
- .flags = 0,
- .size = {
- 24,
- 24,
- },
-};
-
-#define _ccv_width_padding(x) (((x) + 3) & -4)
-
-static inline int _ccv_run_bbf_feature(ccv_bbf_feature_t *feature, int *step, unsigned char **u8)
-{
-#define pf_at(i) (*(u8[feature->pz[i]] + feature->px[i] + feature->py[i] * step[feature->pz[i]]))
-#define nf_at(i) (*(u8[feature->nz[i]] + feature->nx[i] + feature->ny[i] * step[feature->nz[i]]))
- unsigned char pmin = pf_at(0), nmax = nf_at(0);
- /* check if every point in P > every point in N, and take a shortcut */
- if (pmin <= nmax)
- return 0;
- int i;
- for (i = 1; i < feature->size; i++)
- {
- if (feature->pz[i] >= 0)
- {
- int p = pf_at(i);
- if (p < pmin)
- {
- if (p <= nmax)
- return 0;
- pmin = p;
- }
- }
- if (feature->nz[i] >= 0)
- {
- int n = nf_at(i);
- if (n > nmax)
- {
- if (pmin <= n)
- return 0;
- nmax = n;
- }
- }
- }
-#undef pf_at
-#undef nf_at
- return 1;
-}
diff --git a/test/source.c++ b/test/source.c++
deleted file mode 100644
index 97e29e8..0000000
--- a/test/source.c++
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "ccv.h"
-#include "ccv_internal.h"
-#include
-#ifdef HAVE_GSL
-#include
-#include
-#endif
-#ifdef USE_OPENMP
-#include
-#endif
-
-const ccv_bbf_param_t ccv_bbf_default_params = {
- .interval = 5,
- .min_neighbors = 2,
- .accurate = 1,
- .flags = 0,
- .size = {
- 24,
- 24,
- },
-};
-
-#define _ccv_width_padding(x) (((x) + 3) & -4)
-
-static inline int _ccv_run_bbf_feature(ccv_bbf_feature_t* feature, int* step, unsigned char** u8)
-{
-#define pf_at(i) (*(u8[feature->pz[i]] + feature->px[i] + feature->py[i] * step[feature->pz[i]]))
-#define nf_at(i) (*(u8[feature->nz[i]] + feature->nx[i] + feature->ny[i] * step[feature->nz[i]]))
- unsigned char pmin = pf_at(0), nmax = nf_at(0);
- /* check if every point in P > every point in N, and take a shortcut */
- if (pmin <= nmax)
- return 0;
- int i;
- for (i = 1; i < feature->size; i++)
- {
- if (feature->pz[i] >= 0)
- {
- int p = pf_at(i);
- if (p < pmin)
- {
- if (p <= nmax)
- return 0;
- pmin = p;
- }
- }
- if (feature->nz[i] >= 0)
- {
- int n = nf_at(i);
- if (n > nmax)
- {
- if (pmin <= n)
- return 0;
- nmax = n;
- }
- }
- }
-#undef pf_at
-#undef nf_at
- return 1;
-}
-
-static int _ccv_read_bbf_stage_classifier(const char* file, ccv_bbf_stage_classifier_t* classifier)
-{
- FILE* r = fopen(file, "r");
- if (r == 0) return -1;
- int stat = 0;
- stat |= fscanf(r, "%d", &classifier->count);
- union { float fl; int i; } fli;
- stat |= fscanf(r, "%d", &fli.i);
- classifier->threshold = fli.fl;
- classifier->feature = (ccv_bbf_feature_t*)ccmalloc(classifier->count * sizeof(ccv_bbf_feature_t));
- classifier->alpha = (float*)ccmalloc(classifier->count * 2 * sizeof(float));
- int i, j;
- for (i = 0; i < classifier->count; i++)
- {
- stat |= fscanf(r, "%d", &classifier->feature[i].size);
- for (j = 0; j < classifier->feature[i].size; j++)
- {
- stat |= fscanf(r, "%d %d %d", &classifier->feature[i].px[j], &classifier->feature[i].py[j], &classifier->feature[i].pz[j]);
- stat |= fscanf(r, "%d %d %d", &classifier->feature[i].nx[j], &classifier->feature[i].ny[j], &classifier->feature[i].nz[j]);
- }
- union { float fl; int i; } flia, flib;
- stat |= fscanf(r, "%d %d", &flia.i, &flib.i);
- classifier->alpha[i * 2] = flia.fl;
- classifier->alpha[i * 2 + 1] = flib.fl;
- }
- fclose(r);
- return 0;
-}
-
-#ifdef HAVE_GSL
\ No newline at end of file
diff --git a/test/source.cc b/test/source.cc
deleted file mode 100644
index 644923c..0000000
--- a/test/source.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "ccv.h"
-#include "ccv_internal.h"
-#include
-#ifdef HAVE_GSL
-#include
-#include
-#endif
-#ifdef USE_OPENMP
-#include
-#endif
-
-const ccv_bbf_param_t ccv_bbf_default_params = {
- .interval = 5,
- .min_neighbors = 2,
- .accurate = 1,
- .flags = 0,
- .size = {
- 24,
- 24,
- },
-};
-
-#define _ccv_width_padding(x) (((x) + 3) & -4)
-
-static inline int _ccv_run_bbf_feature(ccv_bbf_feature_t *feature, int *step, unsigned char **u8)
-{
-#define pf_at(i) (*(u8[feature->pz[i]] + feature->px[i] + feature->py[i] * step[feature->pz[i]]))
-#define nf_at(i) (*(u8[feature->nz[i]] + feature->nx[i] + feature->ny[i] * step[feature->nz[i]]))
- unsigned char pmin = pf_at(0), nmax = nf_at(0);
- /* check if every point in P > every point in N, and take a shortcut */
- if (pmin <= nmax)
- return 0;
- int i;
- for (i = 1; i < feature->size; i++)
- {
- if (feature->pz[i] >= 0)
- {
- int p = pf_at(i);
- if (p < pmin)
- {
- if (p <= nmax)
- return 0;
- pmin = p;
- }
- }
- if (feature->nz[i] >= 0)
- {
- int n = nf_at(i);
- if (n > nmax)
- {
- if (pmin <= n)
- return 0;
- nmax = n;
- }
- }
- }
-#undef pf_at
-#undef nf_at
- return 1;
-}
diff --git a/test/source.clj b/test/source.clj
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.coffee b/test/source.coffee
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.cpp b/test/source.cpp
deleted file mode 100644
index 793837f..0000000
--- a/test/source.cpp
+++ /dev/null
@@ -1,1582 +0,0 @@
-#include "ccv.h"
-#include "ccv_internal.h"
-#include
-#ifdef HAVE_GSL
-#include
-#include
-#endif
-#ifdef USE_OPENMP
-#include
-#endif
-const ;
-
-finitario crear_finitario(info_t i) {
- finitario nuevo = new rep_finitario;
- nuevo->dato = i;
- nuevo->primerio = NULL;
- return nuevo;
-}
-
-
-const ccv_bbf_param_t ccv_bbf_default_params = {
- .interval = 5,
- .min_neighbors = 2,
- .accurate = 1,
- .flags = 0,
- .size = {
- 24,
- 24,
- },
-};
-
-#define _ccv_width_padding(x) (((x) + 3) & -4)
-
-static inline int _ccv_run_bbf_feature(ccv_bbf_feature_t *feature, int *step, unsigned char **u8)
-{
-#define pf_at(i) (*(u8[feature->pz[i]] + feature->px[i] + feature->py[i] * step[feature->pz[i]]))
-#define nf_at(i) (*(u8[feature->nz[i]] + feature->nx[i] + feature->ny[i] * step[feature->nz[i]]))
- unsigned char pmin = pf_at(0), nmax = nf_at(0);
- /* check if every point in P > every point in N, and take a shortcut */
- if (pmin <= nmax)
- return 0;
- int i;
- for (i = 1; i < feature->size; i++)
- {
- if (feature->pz[i] >= 0)
- {
- int p = pf_at(i);
- if (p < pmin)
- {
- if (p <= nmax)
- return 0;
- pmin = p;
- }
- }
- if (feature->nz[i] >= 0)
- {
- int n = nf_at(i);
- if (n > nmax)
- {
- if (pmin <= n)
- return 0;
- nmax = n;
- }
- }
- }
-#undef pf_at
-#undef nf_at
- return 1;
-}
-
-static int _ccv_read_bbf_stage_classifier(const char *file, ccv_bbf_stage_classifier_t *classifier)
-{
- FILE *r = fopen(file, "r");
- if (r == 0)
- return -1;
- int stat = 0;
- stat |= fscanf(r, "%d", &classifier->count);
- union {
- float fl;
- int i;
- } fli;
- stat |= fscanf(r, "%d", &fli.i);
- classifier->threshold = fli.fl;
- classifier->feature = (ccv_bbf_feature_t *)ccmalloc(classifier->count * sizeof(ccv_bbf_feature_t));
- classifier->alpha = (float *)ccmalloc(classifier->count * 2 * sizeof(float));
- int i, j;
- for (i = 0; i < classifier->count; i++)
- {
- stat |= fscanf(r, "%d", &classifier->feature[i].size);
- for (j = 0; j < classifier->feature[i].size; j++)
- {
- stat |= fscanf(r, "%d %d %d", &classifier->feature[i].px[j], &classifier->feature[i].py[j], &classifier->feature[i].pz[j]);
- stat |= fscanf(r, "%d %d %d", &classifier->feature[i].nx[j], &classifier->feature[i].ny[j], &classifier->feature[i].nz[j]);
- }
- union {
- float fl;
- int i;
- } flia, flib;
- stat |= fscanf(r, "%d %d", &flia.i, &flib.i);
- classifier->alpha[i * 2] = flia.fl;
- classifier->alpha[i * 2 + 1] = flib.fl;
- }
- fclose(r);
- return 0;
-}
-
-#ifdef HAVE_GSL
-
-static unsigned int _ccv_bbf_time_measure()
-{
- struct timeval tv;
- gettimeofday(&tv, 0);
- return tv.tv_sec * 1000000 + tv.tv_usec;
-}
-
-#define less_than(a, b, aux) ((a) < (b))
-CCV_IMPLEMENT_QSORT(_ccv_sort_32f, float, less_than)
-#undef less_than
-
-static void _ccv_bbf_eval_data(ccv_bbf_stage_classifier_t *classifier, unsigned char **posdata, int posnum, unsigned char **negdata, int negnum, ccv_size_t size, float *peval, float *neval)
-{
- int i, j;
- int steps[] = {_ccv_width_padding(size.width),
- _ccv_width_padding(size.width >> 1),
- _ccv_width_padding(size.width >> 2)};
- int isizs0 = steps[0] * size.height;
- int isizs01 = isizs0 + steps[1] * (size.height >> 1);
- for (i = 0; i < posnum; i++)
- {
- unsigned char *u8[] = {posdata[i], posdata[i] + isizs0, posdata[i] + isizs01};
- float sum = 0;
- float *alpha = classifier->alpha;
- ccv_bbf_feature_t *feature = classifier->feature;
- for (j = 0; j < classifier->count; ++j, alpha += 2, ++feature)
- sum += alpha[_ccv_run_bbf_feature(feature, steps, u8)];
- peval[i] = sum;
- }
- for (i = 0; i < negnum; i++)
- {
- unsigned char *u8[] = {negdata[i], negdata[i] + isizs0, negdata[i] + isizs01};
- float sum = 0;
- float *alpha = classifier->alpha;
- ccv_bbf_feature_t *feature = classifier->feature;
- for (j = 0; j < classifier->count; ++j, alpha += 2, ++feature)
- sum += alpha[_ccv_run_bbf_feature(feature, steps, u8)];
- neval[i] = sum;
- }
-}
-
-static int _ccv_prune_positive_data(ccv_bbf_classifier_cascade_t *cascade, unsigned char **posdata, int posnum, ccv_size_t size)
-{
- float *peval = (float *)ccmalloc(posnum * sizeof(float));
- int i, j, k, rpos = posnum;
- for (i = 0; i < cascade->count; i++)
- {
- _ccv_bbf_eval_data(cascade->stage_classifier + i, posdata, rpos, 0, 0, size, peval, 0);
- k = 0;
- for (j = 0; j < rpos; j++)
- if (peval[j] >= cascade->stage_classifier[i].threshold)
- {
- posdata[k] = posdata[j];
- ++k;
- }
- else
- {
- ccfree(posdata[j]);
- }
- rpos = k;
- }
- ccfree(peval);
- return rpos;
-}
-
-static int _ccv_prepare_background_data(ccv_bbf_classifier_cascade_t *cascade, char **bgfiles, int bgnum, unsigned char **negdata, int negnum)
-{
- int t, i, j, k, q;
- int negperbg;
- int negtotal = 0;
- int steps[] = {_ccv_width_padding(cascade->size.width),
- _ccv_width_padding(cascade->size.width >> 1),
- _ccv_width_padding(cascade->size.width >> 2)};
- int isizs0 = steps[0] * cascade->size.height;
- int isizs1 = steps[1] * (cascade->size.height >> 1);
- int isizs2 = steps[2] * (cascade->size.height >> 2);
- int *idcheck = (int *)ccmalloc(negnum * sizeof(int));
-
- gsl_rng_env_setup();
-
- gsl_rng *rng = gsl_rng_alloc(gsl_rng_default);
- gsl_rng_set(rng, (unsigned long int)idcheck);
-
- ccv_size_t imgsz = cascade->size;
- int rneg = negtotal;
- for (t = 0; negtotal < negnum; t++)
- {
- PRINT(CCV_CLI_INFO, "preparing negative data ... 0%%");
- for (i = 0; i < bgnum; i++)
- {
- negperbg = (t < 2) ? (negnum - negtotal) / (bgnum - i) + 1 : negnum - negtotal;
- ccv_dense_matrix_t *image = 0;
- ccv_read(bgfiles[i], &image, CCV_IO_GRAY | CCV_IO_ANY_FILE);
- assert((image->type & CCV_C1) && (image->type & CCV_8U));
- if (image == 0)
- {
- PRINT(CCV_CLI_ERROR, "\n%s file corrupted\n", bgfiles[i]);
- continue;
- }
- if (t % 2 != 0)
- ccv_flip(image, 0, 0, CCV_FLIP_X);
- if (t % 4 >= 2)
- ccv_flip(image, 0, 0, CCV_FLIP_Y);
- ccv_bbf_param_t params = {.interval = 3, .min_neighbors = 0, .accurate = 1, .flags = 0, .size = cascade->size};
- ccv_array_t *detected = ccv_bbf_detect_objects(image, &cascade, 1, params);
- memset(idcheck, 0, ccv_min(detected->rnum, negperbg) * sizeof(int));
- for (j = 0; j < ccv_min(detected->rnum, negperbg); j++)
- {
- int r = gsl_rng_uniform_int(rng, detected->rnum);
- int flag = 1;
- ccv_rect_t *rect = (ccv_rect_t *)ccv_array_get(detected, r);
- while (flag)
- {
- flag = 0;
- for (k = 0; k < j; k++)
- if (r == idcheck[k])
- {
- flag = 1;
- r = gsl_rng_uniform_int(rng, detected->rnum);
- break;
- }
- rect = (ccv_rect_t *)ccv_array_get(detected, r);
- if ((rect->x < 0) || (rect->y < 0) || (rect->width + rect->x > image->cols) || (rect->height + rect->y > image->rows))
- {
- flag = 1;
- r = gsl_rng_uniform_int(rng, detected->rnum);
- }
- }
- idcheck[j] = r;
- ccv_dense_matrix_t *temp = 0;
- ccv_dense_matrix_t *imgs0 = 0;
- ccv_dense_matrix_t *imgs1 = 0;
- ccv_dense_matrix_t *imgs2 = 0;
- ccv_slice(image, (ccv_matrix_t **)&temp, 0, rect->y, rect->x, rect->height, rect->width);
- ccv_resample(temp, &imgs0, 0, imgsz.height, imgsz.width, CCV_INTER_AREA);
- assert(imgs0->step == steps[0]);
- ccv_matrix_free(temp);
- ccv_sample_down(imgs0, &imgs1, 0, 0, 0);
- assert(imgs1->step == steps[1]);
- ccv_sample_down(imgs1, &imgs2, 0, 0, 0);
- assert(imgs2->step == steps[2]);
-
- negdata[negtotal] = (unsigned char *)ccmalloc(isizs0 + isizs1 + isizs2);
- unsigned char *u8s0 = negdata[negtotal];
- unsigned char *u8s1 = negdata[negtotal] + isizs0;
- unsigned char *u8s2 = negdata[negtotal] + isizs0 + isizs1;
- unsigned char *u8[] = {u8s0, u8s1, u8s2};
- memcpy(u8s0, imgs0->data.u8, imgs0->rows * imgs0->step);
- ccv_matrix_free(imgs0);
- memcpy(u8s1, imgs1->data.u8, imgs1->rows * imgs1->step);
- ccv_matrix_free(imgs1);
- memcpy(u8s2, imgs2->data.u8, imgs2->rows * imgs2->step);
- ccv_matrix_free(imgs2);
-
- flag = 1;
- ccv_bbf_stage_classifier_t *classifier = cascade->stage_classifier;
- for (k = 0; k < cascade->count; ++k, ++classifier)
- {
- float sum = 0;
- float *alpha = classifier->alpha;
- ccv_bbf_feature_t *feature = classifier->feature;
- for (q = 0; q < classifier->count; ++q, alpha += 2, ++feature)
- sum += alpha[_ccv_run_bbf_feature(feature, steps, u8)];
- if (sum < classifier->threshold)
- {
- flag = 0;
- break;
- }
- }
- if (!flag)
- ccfree(negdata[negtotal]);
- else
- {
- ++negtotal;
- if (negtotal >= negnum)
- break;
- }
- }
- ccv_array_free(detected);
- ccv_matrix_free(image);
- ccv_drain_cache();
- PRINT(CCV_CLI_INFO, "\rpreparing negative data ... %2d%%", 100 * negtotal / negnum);
- fflush(0);
- if (negtotal >= negnum)
- break;
- }
- if (rneg == negtotal)
- break;
- rneg = negtotal;
- PRINT(CCV_CLI_INFO, "\nentering additional round %d\n", t + 1);
- }
- gsl_rng_free(rng);
- ccfree(idcheck);
- ccv_drain_cache();
- PRINT(CCV_CLI_INFO, "\n");
- return negtotal;
-}
-
-static void _ccv_prepare_positive_data(ccv_dense_matrix_t **posimg, unsigned char **posdata, ccv_size_t size, int posnum)
-{
- PRINT(CCV_CLI_INFO, "preparing positive data ... 0%%");
- int i;
- for (i = 0; i < posnum; i++)
- {
- ccv_dense_matrix_t *imgs0 = posimg[i];
- ccv_dense_matrix_t *imgs1 = 0;
- ccv_dense_matrix_t *imgs2 = 0;
- assert((imgs0->type & CCV_C1) && (imgs0->type & CCV_8U) && imgs0->rows == size.height && imgs0->cols == size.width);
- ccv_sample_down(imgs0, &imgs1, 0, 0, 0);
- ccv_sample_down(imgs1, &imgs2, 0, 0, 0);
- int isizs0 = imgs0->rows * imgs0->step;
- int isizs1 = imgs1->rows * imgs1->step;
- int isizs2 = imgs2->rows * imgs2->step;
-
- posdata[i] = (unsigned char *)ccmalloc(isizs0 + isizs1 + isizs2);
- memcpy(posdata[i], imgs0->data.u8, isizs0);
- memcpy(posdata[i] + isizs0, imgs1->data.u8, isizs1);
- memcpy(posdata[i] + isizs0 + isizs1, imgs2->data.u8, isizs2);
-
- PRINT(CCV_CLI_INFO, "\rpreparing positive data ... %2d%%", 100 * (i + 1) / posnum);
- fflush(0);
-
- ccv_matrix_free(imgs1);
- ccv_matrix_free(imgs2);
- }
- ccv_drain_cache();
- PRINT(CCV_CLI_INFO, "\n");
-}
-
-typedef struct
-{
- double fitness;
- int pk, nk;
- int age;
- double error;
- ccv_bbf_feature_t feature;
-} ccv_bbf_gene_t;
-
-static inline void _ccv_bbf_genetic_fitness(ccv_bbf_gene_t *gene)
-{
- gene->fitness = (1 - gene->error) * exp(-0.01 * gene->age) * exp((gene->pk + gene->nk) * log(1.015));
-}
-
-static inline int _ccv_bbf_exist_gene_feature(ccv_bbf_gene_t *gene, int x, int y, int z)
-{
- int i;
- for (i = 0; i < gene->pk; i++)
- if (z == gene->feature.pz[i] && x == gene->feature.px[i] && y == gene->feature.py[i])
- return 1;
- for (i = 0; i < gene->nk; i++)
- if (z == gene->feature.nz[i] && x == gene->feature.nx[i] && y == gene->feature.ny[i])
- return 1;
- return 0;
-}
-
-static inline void _ccv_bbf_randomize_gene(gsl_rng *rng, ccv_bbf_gene_t *gene, int *rows, int *cols)
-{
- int i;
- do
- {
- gene->pk = gsl_rng_uniform_int(rng, CCV_BBF_POINT_MAX - 1) + 1;
- gene->nk = gsl_rng_uniform_int(rng, CCV_BBF_POINT_MAX - 1) + 1;
- } while (gene->pk + gene->nk < CCV_BBF_POINT_MIN); /* a hard restriction of at least 3 points have to be examed */
- gene->feature.size = ccv_max(gene->pk, gene->nk);
- gene->age = 0;
- for (i = 0; i < CCV_BBF_POINT_MAX; i++)
- {
- gene->feature.pz[i] = -1;
- gene->feature.nz[i] = -1;
- }
- int x, y, z;
- for (i = 0; i < gene->pk; i++)
- {
- do
- {
- z = gsl_rng_uniform_int(rng, 3);
- x = gsl_rng_uniform_int(rng, cols[z]);
- y = gsl_rng_uniform_int(rng, rows[z]);
- } while (_ccv_bbf_exist_gene_feature(gene, x, y, z));
- gene->feature.pz[i] = z;
- gene->feature.px[i] = x;
- gene->feature.py[i] = y;
- }
- for (i = 0; i < gene->nk; i++)
- {
- do
- {
- z = gsl_rng_uniform_int(rng, 3);
- x = gsl_rng_uniform_int(rng, cols[z]);
- y = gsl_rng_uniform_int(rng, rows[z]);
- } while (_ccv_bbf_exist_gene_feature(gene, x, y, z));
- gene->feature.nz[i] = z;
- gene->feature.nx[i] = x;
- gene->feature.ny[i] = y;
- }
-}
-
-static inline double _ccv_bbf_error_rate(ccv_bbf_feature_t *feature, unsigned char **posdata, int posnum, unsigned char **negdata, int negnum, ccv_size_t size, double *pw, double *nw)
-{
- int i;
- int steps[] = {_ccv_width_padding(size.width),
- _ccv_width_padding(size.width >> 1),
- _ccv_width_padding(size.width >> 2)};
- int isizs0 = steps[0] * size.height;
- int isizs01 = isizs0 + steps[1] * (size.height >> 1);
- double error = 0;
- for (i = 0; i < posnum; i++)
- {
- unsigned char *u8[] = {posdata[i], posdata[i] + isizs0, posdata[i] + isizs01};
- if (!_ccv_run_bbf_feature(feature, steps, u8))
- error += pw[i];
- }
- for (i = 0; i < negnum; i++)
- {
- unsigned char *u8[] = {negdata[i], negdata[i] + isizs0, negdata[i] + isizs01};
- if (_ccv_run_bbf_feature(feature, steps, u8))
- error += nw[i];
- }
- return error;
-}
-
-#define less_than(fit1, fit2, aux) ((fit1).fitness >= (fit2).fitness)
-static CCV_IMPLEMENT_QSORT(_ccv_bbf_genetic_qsort, ccv_bbf_gene_t, less_than)
-#undef less_than
-
- static ccv_bbf_feature_t _ccv_bbf_genetic_optimize(unsigned char **posdata, int posnum, unsigned char **negdata, int negnum, int ftnum, ccv_size_t size, double *pw, double *nw)
-{
- ccv_bbf_feature_t best;
- /* seed (random method) */
- gsl_rng_env_setup();
- gsl_rng *rng = gsl_rng_alloc(gsl_rng_default);
- union {
- unsigned long int li;
- double db;
- } dbli;
- dbli.db = pw[0] + nw[0];
- gsl_rng_set(rng, dbli.li);
- int i, j;
- int pnum = ftnum * 100;
- assert(pnum > 0);
- ccv_bbf_gene_t *gene = (ccv_bbf_gene_t *)ccmalloc(pnum * sizeof(ccv_bbf_gene_t));
- int rows[] = {size.height, size.height >> 1, size.height >> 2};
- int cols[] = {size.width, size.width >> 1, size.width >> 2};
- for (i = 0; i < pnum; i++)
- _ccv_bbf_randomize_gene(rng, &gene[i], rows, cols);
- unsigned int timer = _ccv_bbf_time_measure();
-#ifdef USE_OPENMP
-#pragma omp parallel for private(i) schedule(dynamic)
-#endif
- for (i = 0; i < pnum; i++)
- gene[i].error = _ccv_bbf_error_rate(&gene[i].feature, posdata, posnum, negdata, negnum, size, pw, nw);
- timer = _ccv_bbf_time_measure() - timer;
- for (i = 0; i < pnum; i++)
- _ccv_bbf_genetic_fitness(&gene[i]);
- double best_err = 1;
- int rnum = ftnum * 39; /* number of randomize */
- int mnum = ftnum * 40; /* number of mutation */
- int hnum = ftnum * 20; /* number of hybrid */
- /* iteration stop crit : best no change in 40 iterations */
- int it = 0, t;
- for (t = 0; it < 40; ++it, ++t)
- {
- int min_id = 0;
- double min_err = gene[0].error;
- for (i = 1; i < pnum; i++)
- if (gene[i].error < min_err)
- {
- min_id = i;
- min_err = gene[i].error;
- }
- min_err = gene[min_id].error = _ccv_bbf_error_rate(&gene[min_id].feature, posdata, posnum, negdata, negnum, size, pw, nw);
- if (min_err < best_err)
- {
- best_err = min_err;
- memcpy(&best, &gene[min_id].feature, sizeof(best));
- PRINT(CCV_CLI_INFO, "best bbf feature with error %f\n|-size: %d\n|-positive point: ", best_err, best.size);
- for (i = 0; i < best.size; i++)
- PRINT(CCV_CLI_INFO, "(%d %d %d), ", best.px[i], best.py[i], best.pz[i]);
- PRINT(CCV_CLI_INFO, "\n|-negative point: ");
- for (i = 0; i < best.size; i++)
- PRINT(CCV_CLI_INFO, "(%d %d %d), ", best.nx[i], best.ny[i], best.nz[i]);
- PRINT(CCV_CLI_INFO, "\n");
- it = 0;
- }
- PRINT(CCV_CLI_INFO, "minimum error achieved in round %d(%d) : %f with %d ms\n", t, it, min_err, timer / 1000);
- _ccv_bbf_genetic_qsort(gene, pnum, 0);
- for (i = 0; i < ftnum; i++)
- ++gene[i].age;
- for (i = ftnum; i < ftnum + mnum; i++)
- {
- int parent = gsl_rng_uniform_int(rng, ftnum);
- memcpy(gene + i, gene + parent, sizeof(ccv_bbf_gene_t));
- /* three mutation strategy : 1. add, 2. remove, 3. refine */
- int pnm, pn = gsl_rng_uniform_int(rng, 2);
- int *pnk[] = {&gene[i].pk, &gene[i].nk};
- int *pnx[] = {gene[i].feature.px, gene[i].feature.nx};
- int *pny[] = {gene[i].feature.py, gene[i].feature.ny};
- int *pnz[] = {gene[i].feature.pz, gene[i].feature.nz};
- int x, y, z;
- int victim, decay = 1;
- do
- {
- switch (gsl_rng_uniform_int(rng, 3))
- {
- case 0: /* add */
- if (gene[i].pk == CCV_BBF_POINT_MAX && gene[i].nk == CCV_BBF_POINT_MAX)
- break;
- while (*pnk[pn] + 1 > CCV_BBF_POINT_MAX)
- pn = gsl_rng_uniform_int(rng, 2);
- do
- {
- z = gsl_rng_uniform_int(rng, 3);
- x = gsl_rng_uniform_int(rng, cols[z]);
- y = gsl_rng_uniform_int(rng, rows[z]);
- } while (_ccv_bbf_exist_gene_feature(&gene[i], x, y, z));
- pnz[pn][*pnk[pn]] = z;
- pnx[pn][*pnk[pn]] = x;
- pny[pn][*pnk[pn]] = y;
- ++(*pnk[pn]);
- gene[i].feature.size = ccv_max(gene[i].pk, gene[i].nk);
- decay = gene[i].age = 0;
- break;
- case 1: /* remove */
- if (gene[i].pk + gene[i].nk <= CCV_BBF_POINT_MIN) /* at least 3 points have to be examed */
- break;
- while (*pnk[pn] - 1 <= 0) // || *pnk[pn] + *pnk[!pn] - 1 < CCV_BBF_POINT_MIN)
- pn = gsl_rng_uniform_int(rng, 2);
- victim = gsl_rng_uniform_int(rng, *pnk[pn]);
- for (j = victim; j < *pnk[pn] - 1; j++)
- {
- pnz[pn][j] = pnz[pn][j + 1];
- pnx[pn][j] = pnx[pn][j + 1];
- pny[pn][j] = pny[pn][j + 1];
- }
- pnz[pn][*pnk[pn] - 1] = -1;
- --(*pnk[pn]);
- gene[i].feature.size = ccv_max(gene[i].pk, gene[i].nk);
- decay = gene[i].age = 0;
- break;
- case 2: /* refine */
- pnm = gsl_rng_uniform_int(rng, *pnk[pn]);
- do
- {
- z = gsl_rng_uniform_int(rng, 3);
- x = gsl_rng_uniform_int(rng, cols[z]);
- y = gsl_rng_uniform_int(rng, rows[z]);
- } while (_ccv_bbf_exist_gene_feature(&gene[i], x, y, z));
- pnz[pn][pnm] = z;
- pnx[pn][pnm] = x;
- pny[pn][pnm] = y;
- decay = gene[i].age = 0;
- break;
- }
- } while (decay);
- }
- for (i = ftnum + mnum; i < ftnum + mnum + hnum; i++)
- {
- /* hybrid strategy: taking positive points from dad, negative points from mum */
- int dad, mum;
- do
- {
- dad = gsl_rng_uniform_int(rng, ftnum);
- mum = gsl_rng_uniform_int(rng, ftnum);
- } while (dad == mum || gene[dad].pk + gene[mum].nk < CCV_BBF_POINT_MIN); /* at least 3 points have to be examed */
- for (j = 0; j < CCV_BBF_POINT_MAX; j++)
- {
- gene[i].feature.pz[j] = -1;
- gene[i].feature.nz[j] = -1;
- }
- gene[i].pk = gene[dad].pk;
- for (j = 0; j < gene[i].pk; j++)
- {
- gene[i].feature.pz[j] = gene[dad].feature.pz[j];
- gene[i].feature.px[j] = gene[dad].feature.px[j];
- gene[i].feature.py[j] = gene[dad].feature.py[j];
- }
- gene[i].nk = gene[mum].nk;
- for (j = 0; j < gene[i].nk; j++)
- {
- gene[i].feature.nz[j] = gene[mum].feature.nz[j];
- gene[i].feature.nx[j] = gene[mum].feature.nx[j];
- gene[i].feature.ny[j] = gene[mum].feature.ny[j];
- }
- gene[i].feature.size = ccv_max(gene[i].pk, gene[i].nk);
- gene[i].age = 0;
- }
- for (i = ftnum + mnum + hnum; i < ftnum + mnum + hnum + rnum; i++)
- _ccv_bbf_randomize_gene(rng, &gene[i], rows, cols);
- timer = _ccv_bbf_time_measure();
-#ifdef USE_OPENMP
-#pragma omp parallel for private(i) schedule(dynamic)
-#endif
- for (i = 0; i < pnum; i++)
- gene[i].error = _ccv_bbf_error_rate(&gene[i].feature, posdata, posnum, negdata, negnum, size, pw, nw);
- timer = _ccv_bbf_time_measure() - timer;
- for (i = 0; i < pnum; i++)
- _ccv_bbf_genetic_fitness(&gene[i]);
- }
- ccfree(gene);
- gsl_rng_free(rng);
- return best;
-}
-
-#define less_than(fit1, fit2, aux) ((fit1).error < (fit2).error)
-static CCV_IMPLEMENT_QSORT(_ccv_bbf_best_qsort, ccv_bbf_gene_t, less_than)
-#undef less_than
-
- static ccv_bbf_gene_t _ccv_bbf_best_gene(ccv_bbf_gene_t *gene, int pnum, int point_min, unsigned char **posdata, int posnum, unsigned char **negdata, int negnum, ccv_size_t size, double *pw, double *nw)
-{
- int i;
- unsigned int timer = _ccv_bbf_time_measure();
-#ifdef USE_OPENMP
-#pragma omp parallel for private(i) schedule(dynamic)
-#endif
- for (i = 0; i < pnum; i++)
- gene[i].error = _ccv_bbf_error_rate(&gene[i].feature, posdata, posnum, negdata, negnum, size, pw, nw);
- timer = _ccv_bbf_time_measure() - timer;
- _ccv_bbf_best_qsort(gene, pnum, 0);
- int min_id = 0;
- double min_err = gene[0].error;
- for (i = 0; i < pnum; i++)
- if (gene[i].nk + gene[i].pk >= point_min)
- {
- min_id = i;
- min_err = gene[i].error;
- break;
- }
- PRINT(CCV_CLI_INFO, "local best bbf feature with error %f\n|-size: %d\n|-positive point: ", min_err, gene[min_id].feature.size);
- for (i = 0; i < gene[min_id].feature.size; i++)
- PRINT(CCV_CLI_INFO, "(%d %d %d), ", gene[min_id].feature.px[i], gene[min_id].feature.py[i], gene[min_id].feature.pz[i]);
- PRINT(CCV_CLI_INFO, "\n|-negative point: ");
- for (i = 0; i < gene[min_id].feature.size; i++)
- PRINT(CCV_CLI_INFO, "(%d %d %d), ", gene[min_id].feature.nx[i], gene[min_id].feature.ny[i], gene[min_id].feature.nz[i]);
- PRINT(CCV_CLI_INFO, "\nthe computation takes %d ms\n", timer / 1000);
- return gene[min_id];
-}
-
-static ccv_bbf_feature_t _ccv_bbf_convex_optimize(unsigned char **posdata, int posnum, unsigned char **negdata, int negnum, ccv_bbf_feature_t *best_feature, ccv_size_t size, double *pw, double *nw)
-{
- ccv_bbf_gene_t best_gene;
- /* seed (random method) */
- gsl_rng_env_setup();
- gsl_rng *rng = gsl_rng_alloc(gsl_rng_default);
- union {
- unsigned long int li;
- double db;
- } dbli;
- dbli.db = pw[0] + nw[0];
- gsl_rng_set(rng, dbli.li);
- int i, j, k, q, p, g, t;
- int rows[] = {size.height, size.height >> 1, size.height >> 2};
- int cols[] = {size.width, size.width >> 1, size.width >> 2};
- int pnum = rows[0] * cols[0] + rows[1] * cols[1] + rows[2] * cols[2];
- ccv_bbf_gene_t *gene = (ccv_bbf_gene_t *)ccmalloc((pnum * (CCV_BBF_POINT_MAX * 2 + 1) * 2 + CCV_BBF_POINT_MAX * 2 + 1) * sizeof(ccv_bbf_gene_t));
- if (best_feature == 0)
- {
- /* bootstrapping the best feature, start from two pixels, one for positive, one for negative
- * the bootstrapping process go like this: first, it will assign a random pixel as positive
- * and enumerate every possible pixel as negative, and pick the best one. Then, enumerate every
- * possible pixel as positive, and pick the best one, until it converges */
- memset(&best_gene, 0, sizeof(ccv_bbf_gene_t));
- for (i = 0; i < CCV_BBF_POINT_MAX; i++)
- best_gene.feature.pz[i] = best_gene.feature.nz[i] = -1;
- best_gene.pk = 1;
- best_gene.nk = 0;
- best_gene.feature.size = 1;
- best_gene.feature.pz[0] = gsl_rng_uniform_int(rng, 3);
- best_gene.feature.px[0] = gsl_rng_uniform_int(rng, cols[best_gene.feature.pz[0]]);
- best_gene.feature.py[0] = gsl_rng_uniform_int(rng, rows[best_gene.feature.pz[0]]);
- for (t = 0;; ++t)
- {
- g = 0;
- if (t % 2 == 0)
- {
- for (i = 0; i < 3; i++)
- for (j = 0; j < cols[i]; j++)
- for (k = 0; k < rows[i]; k++)
- if (i != best_gene.feature.pz[0] || j != best_gene.feature.px[0] || k != best_gene.feature.py[0])
- {
- gene[g] = best_gene;
- gene[g].pk = gene[g].nk = 1;
- gene[g].feature.nz[0] = i;
- gene[g].feature.nx[0] = j;
- gene[g].feature.ny[0] = k;
- g++;
- }
- }
- else
- {
- for (i = 0; i < 3; i++)
- for (j = 0; j < cols[i]; j++)
- for (k = 0; k < rows[i]; k++)
- if (i != best_gene.feature.nz[0] || j != best_gene.feature.nx[0] || k != best_gene.feature.ny[0])
- {
- gene[g] = best_gene;
- gene[g].pk = gene[g].nk = 1;
- gene[g].feature.pz[0] = i;
- gene[g].feature.px[0] = j;
- gene[g].feature.py[0] = k;
- g++;
- }
- }
- PRINT(CCV_CLI_INFO, "bootstrapping round : %d\n", t);
- ccv_bbf_gene_t local_gene = _ccv_bbf_best_gene(gene, g, 2, posdata, posnum, negdata, negnum, size, pw, nw);
- if (local_gene.error >= best_gene.error - 1e-10)
- break;
- best_gene = local_gene;
- }
- }
- else
- {
- best_gene.feature = *best_feature;
- best_gene.pk = best_gene.nk = best_gene.feature.size;
- for (i = 0; i < CCV_BBF_POINT_MAX; i++)
- if (best_feature->pz[i] == -1)
- {
- best_gene.pk = i;
- break;
- }
- for (i = 0; i < CCV_BBF_POINT_MAX; i++)
- if (best_feature->nz[i] == -1)
- {
- best_gene.nk = i;
- break;
- }
- }
- /* after bootstrapping, the float search technique will do the following permutations:
- * a). add a new point to positive or negative
- * b). remove a point from positive or negative
- * c). move an existing point in positive or negative to another position
- * the three rules applied exhaustively, no heuristic used. */
- for (t = 0;; ++t)
- {
- g = 0;
- for (i = 0; i < 3; i++)
- for (j = 0; j < cols[i]; j++)
- for (k = 0; k < rows[i]; k++)
- if (!_ccv_bbf_exist_gene_feature(&best_gene, j, k, i))
- {
- /* add positive point */
- if (best_gene.pk < CCV_BBF_POINT_MAX - 1)
- {
- gene[g] = best_gene;
- gene[g].feature.pz[gene[g].pk] = i;
- gene[g].feature.px[gene[g].pk] = j;
- gene[g].feature.py[gene[g].pk] = k;
- gene[g].pk++;
- gene[g].feature.size = ccv_max(gene[g].pk, gene[g].nk);
- g++;
- }
- /* add negative point */
- if (best_gene.nk < CCV_BBF_POINT_MAX - 1)
- {
- gene[g] = best_gene;
- gene[g].feature.nz[gene[g].nk] = i;
- gene[g].feature.nx[gene[g].nk] = j;
- gene[g].feature.ny[gene[g].nk] = k;
- gene[g].nk++;
- gene[g].feature.size = ccv_max(gene[g].pk, gene[g].nk);
- g++;
- }
- /* refine positive point */
- for (q = 0; q < best_gene.pk; q++)
- {
- gene[g] = best_gene;
- gene[g].feature.pz[q] = i;
- gene[g].feature.px[q] = j;
- gene[g].feature.py[q] = k;
- g++;
- }
- /* add positive point, remove negative point */
- if (best_gene.pk < CCV_BBF_POINT_MAX - 1 && best_gene.nk > 1)
- {
- for (q = 0; q < best_gene.nk; q++)
- {
- gene[g] = best_gene;
- gene[g].feature.pz[gene[g].pk] = i;
- gene[g].feature.px[gene[g].pk] = j;
- gene[g].feature.py[gene[g].pk] = k;
- gene[g].pk++;
- for (p = q; p < best_gene.nk - 1; p++)
- {
- gene[g].feature.nz[p] = gene[g].feature.nz[p + 1];
- gene[g].feature.nx[p] = gene[g].feature.nx[p + 1];
- gene[g].feature.ny[p] = gene[g].feature.ny[p + 1];
- }
- gene[g].feature.nz[gene[g].nk - 1] = -1;
- gene[g].nk--;
- gene[g].feature.size = ccv_max(gene[g].pk, gene[g].nk);
- g++;
- }
- }
- /* refine negative point */
- for (q = 0; q < best_gene.nk; q++)
- {
- gene[g] = best_gene;
- gene[g].feature.nz[q] = i;
- gene[g].feature.nx[q] = j;
- gene[g].feature.ny[q] = k;
- g++;
- }
- /* add negative point, remove positive point */
- if (best_gene.pk > 1 && best_gene.nk < CCV_BBF_POINT_MAX - 1)
- {
- for (q = 0; q < best_gene.pk; q++)
- {
- gene[g] = best_gene;
- gene[g].feature.nz[gene[g].nk] = i;
- gene[g].feature.nx[gene[g].nk] = j;
- gene[g].feature.ny[gene[g].nk] = k;
- gene[g].nk++;
- for (p = q; p < best_gene.pk - 1; p++)
- {
- gene[g].feature.pz[p] = gene[g].feature.pz[p + 1];
- gene[g].feature.px[p] = gene[g].feature.px[p + 1];
- gene[g].feature.py[p] = gene[g].feature.py[p + 1];
- }
- gene[g].feature.pz[gene[g].pk - 1] = -1;
- gene[g].pk--;
- gene[g].feature.size = ccv_max(gene[g].pk, gene[g].nk);
- g++;
- }
- }
- }
- if (best_gene.pk > 1)
- for (q = 0; q < best_gene.pk; q++)
- {
- gene[g] = best_gene;
- for (i = q; i < best_gene.pk - 1; i++)
- {
- gene[g].feature.pz[i] = gene[g].feature.pz[i + 1];
- gene[g].feature.px[i] = gene[g].feature.px[i + 1];
- gene[g].feature.py[i] = gene[g].feature.py[i + 1];
- }
- gene[g].feature.pz[gene[g].pk - 1] = -1;
- gene[g].pk--;
- gene[g].feature.size = ccv_max(gene[g].pk, gene[g].nk);
- g++;
- }
- if (best_gene.nk > 1)
- for (q = 0; q < best_gene.nk; q++)
- {
- gene[g] = best_gene;
- for (i = q; i < best_gene.nk - 1; i++)
- {
- gene[g].feature.nz[i] = gene[g].feature.nz[i + 1];
- gene[g].feature.nx[i] = gene[g].feature.nx[i + 1];
- gene[g].feature.ny[i] = gene[g].feature.ny[i + 1];
- }
- gene[g].feature.nz[gene[g].nk - 1] = -1;
- gene[g].nk--;
- gene[g].feature.size = ccv_max(gene[g].pk, gene[g].nk);
- g++;
- }
- gene[g] = best_gene;
- g++;
- PRINT(CCV_CLI_INFO, "float search round : %d\n", t);
- ccv_bbf_gene_t local_gene = _ccv_bbf_best_gene(gene, g, CCV_BBF_POINT_MIN, posdata, posnum, negdata, negnum, size, pw, nw);
- if (local_gene.error >= best_gene.error - 1e-10)
- break;
- best_gene = local_gene;
- }
- ccfree(gene);
- gsl_rng_free(rng);
- return best_gene.feature;
-}
-
-static int _ccv_write_bbf_stage_classifier(const char *file, ccv_bbf_stage_classifier_t *classifier)
-{
- FILE *w = fopen(file, "wb");
- if (w == 0)
- return -1;
- fprintf(w, "%d\n", classifier->count);
- union {
- float fl;
- int i;
- } fli;
- fli.fl = classifier->threshold;
- fprintf(w, "%d\n", fli.i);
- int i, j;
- for (i = 0; i < classifier->count; i++)
- {
- fprintf(w, "%d\n", classifier->feature[i].size);
- for (j = 0; j < classifier->feature[i].size; j++)
- {
- fprintf(w, "%d %d %d\n", classifier->feature[i].px[j], classifier->feature[i].py[j], classifier->feature[i].pz[j]);
- fprintf(w, "%d %d %d\n", classifier->feature[i].nx[j], classifier->feature[i].ny[j], classifier->feature[i].nz[j]);
- }
- union {
- float fl;
- int i;
- } flia, flib;
- flia.fl = classifier->alpha[i * 2];
- flib.fl = classifier->alpha[i * 2 + 1];
- fprintf(w, "%d %d\n", flia.i, flib.i);
- }
- fclose(w);
- return 0;
-}
-
-static int _ccv_read_background_data(const char *file, unsigned char **negdata, int *negnum, ccv_size_t size)
-{
- int stat = 0;
- FILE *r = fopen(file, "rb");
- if (r == 0)
- return -1;
- stat |= fread(negnum, sizeof(int), 1, r);
- int i;
- int isizs012 = _ccv_width_padding(size.width) * size.height +
- _ccv_width_padding(size.width >> 1) * (size.height >> 1) +
- _ccv_width_padding(size.width >> 2) * (size.height >> 2);
- for (i = 0; i < *negnum; i++)
- {
- negdata[i] = (unsigned char *)ccmalloc(isizs012);
- stat |= fread(negdata[i], 1, isizs012, r);
- }
- fclose(r);
- return 0;
-}
-
-static int _ccv_write_background_data(const char *file, unsigned char **negdata, int negnum, ccv_size_t size)
-{
- FILE *w = fopen(file, "w");
- if (w == 0)
- return -1;
- fwrite(&negnum, sizeof(int), 1, w);
- int i;
- int isizs012 = _ccv_width_padding(size.width) * size.height +
- _ccv_width_padding(size.width >> 1) * (size.height >> 1) +
- _ccv_width_padding(size.width >> 2) * (size.height >> 2);
- for (i = 0; i < negnum; i++)
- fwrite(negdata[i], 1, isizs012, w);
- fclose(w);
- return 0;
-}
-
-static int _ccv_resume_bbf_cascade_training_state(const char *file, int *i, int *k, int *bg, double *pw, double *nw, int posnum, int negnum)
-{
- int stat = 0;
- FILE *r = fopen(file, "r");
- if (r == 0)
- return -1;
- stat |= fscanf(r, "%d %d %d", i, k, bg);
- int j;
- union {
- double db;
- int i[2];
- } dbi;
- for (j = 0; j < posnum; j++)
- {
- stat |= fscanf(r, "%d %d", &dbi.i[0], &dbi.i[1]);
- pw[j] = dbi.db;
- }
- for (j = 0; j < negnum; j++)
- {
- stat |= fscanf(r, "%d %d", &dbi.i[0], &dbi.i[1]);
- nw[j] = dbi.db;
- }
- fclose(r);
- return 0;
-}
-
-static int _ccv_save_bbf_cacade_training_state(const char *file, int i, int k, int bg, double *pw, double *nw, int posnum, int negnum)
-{
- FILE *w = fopen(file, "w");
- if (w == 0)
- return -1;
- fprintf(w, "%d %d %d\n", i, k, bg);
- int j;
- union {
- double db;
- int i[2];
- } dbi;
- for (j = 0; j < posnum; ++j)
- {
- dbi.db = pw[j];
- fprintf(w, "%d %d ", dbi.i[0], dbi.i[1]);
- }
- fprintf(w, "\n");
- for (j = 0; j < negnum; ++j)
- {
- dbi.db = nw[j];
- fprintf(w, "%d %d ", dbi.i[0], dbi.i[1]);
- }
- fprintf(w, "\n");
- fclose(w);
- return 0;
-}
-
-void ccv_bbf_classifier_cascade_new(ccv_dense_matrix_t **posimg, int posnum, char **bgfiles, int bgnum, int negnum, ccv_size_t size, const char *dir, ccv_bbf_new_param_t params)
-{
- int i, j, k;
- /* allocate memory for usage */
- ccv_bbf_classifier_cascade_t *cascade = (ccv_bbf_classifier_cascade_t *)ccmalloc(sizeof(ccv_bbf_classifier_cascade_t));
- cascade->count = 0;
- cascade->size = size;
- cascade->stage_classifier = (ccv_bbf_stage_classifier_t *)ccmalloc(sizeof(ccv_bbf_stage_classifier_t));
- unsigned char **posdata = (unsigned char **)ccmalloc(posnum * sizeof(unsigned char *));
- unsigned char **negdata = (unsigned char **)ccmalloc(negnum * sizeof(unsigned char *));
- double *pw = (double *)ccmalloc(posnum * sizeof(double));
- double *nw = (double *)ccmalloc(negnum * sizeof(double));
- float *peval = (float *)ccmalloc(posnum * sizeof(float));
- float *neval = (float *)ccmalloc(negnum * sizeof(float));
- double inv_balance_k = 1. / params.balance_k;
- /* balance factor k, and weighted with 0.01 */
- params.balance_k *= 0.01;
- inv_balance_k *= 0.01;
-
- int steps[] = {_ccv_width_padding(cascade->size.width),
- _ccv_width_padding(cascade->size.width >> 1),
- _ccv_width_padding(cascade->size.width >> 2)};
- int isizs0 = steps[0] * cascade->size.height;
- int isizs01 = isizs0 + steps[1] * (cascade->size.height >> 1);
-
- i = 0;
- k = 0;
- int bg = 0;
- int cacheK = 10;
- /* state resume code */
- char buf[1024];
- sprintf(buf, "%s/stat.txt", dir);
- _ccv_resume_bbf_cascade_training_state(buf, &i, &k, &bg, pw, nw, posnum, negnum);
- if (i > 0)
- {
- cascade->count = i;
- ccfree(cascade->stage_classifier);
- cascade->stage_classifier = (ccv_bbf_stage_classifier_t *)ccmalloc(i * sizeof(ccv_bbf_stage_classifier_t));
- for (j = 0; j < i; j++)
- {
- sprintf(buf, "%s/stage-%d.txt", dir, j);
- _ccv_read_bbf_stage_classifier(buf, &cascade->stage_classifier[j]);
- }
- }
- if (k > 0)
- cacheK = k;
- int rpos, rneg = 0;
- if (bg)
- {
- sprintf(buf, "%s/negs.txt", dir);
- _ccv_read_background_data(buf, negdata, &rneg, cascade->size);
- }
-
- for (; i < params.layer; i++)
- {
- if (!bg)
- {
- rneg = _ccv_prepare_background_data(cascade, bgfiles, bgnum, negdata, negnum);
- /* save state of background data */
- sprintf(buf, "%s/negs.txt", dir);
- _ccv_write_background_data(buf, negdata, rneg, cascade->size);
- bg = 1;
- }
- double totalw;
- /* save state of cascade : level, weight etc. */
- sprintf(buf, "%s/stat.txt", dir);
- _ccv_save_bbf_cacade_training_state(buf, i, k, bg, pw, nw, posnum, negnum);
- ccv_bbf_stage_classifier_t classifier;
- if (k > 0)
- {
- /* resume state of classifier */
- sprintf(buf, "%s/stage-%d.txt", dir, i);
- _ccv_read_bbf_stage_classifier(buf, &classifier);
- }
- else
- {
- /* initialize classifier */
- for (j = 0; j < posnum; j++)
- pw[j] = params.balance_k;
- for (j = 0; j < rneg; j++)
- nw[j] = inv_balance_k;
- classifier.count = k;
- classifier.threshold = 0;
- classifier.feature = (ccv_bbf_feature_t *)ccmalloc(cacheK * sizeof(ccv_bbf_feature_t));
- classifier.alpha = (float *)ccmalloc(cacheK * 2 * sizeof(float));
- }
- _ccv_prepare_positive_data(posimg, posdata, cascade->size, posnum);
- rpos = _ccv_prune_positive_data(cascade, posdata, posnum, cascade->size);
- PRINT(CCV_CLI_INFO, "%d postivie data and %d negative data in training\n", rpos, rneg);
- /* reweight to 1.00 */
- totalw = 0;
- for (j = 0; j < rpos; j++)
- totalw += pw[j];
- for (j = 0; j < rneg; j++)
- totalw += nw[j];
- for (j = 0; j < rpos; j++)
- pw[j] = pw[j] / totalw;
- for (j = 0; j < rneg; j++)
- nw[j] = nw[j] / totalw;
- for (;; k++)
- {
- /* get overall true-positive, false-positive rate and threshold */
- double tp = 0, fp = 0, etp = 0, efp = 0;
- _ccv_bbf_eval_data(&classifier, posdata, rpos, negdata, rneg, cascade->size, peval, neval);
- _ccv_sort_32f(peval, rpos, 0);
- classifier.threshold = peval[(int)((1. - params.pos_crit) * rpos)] - 1e-6;
- for (j = 0; j < rpos; j++)
- {
- if (peval[j] >= 0)
- ++tp;
- if (peval[j] >= classifier.threshold)
- ++etp;
- }
- tp /= rpos;
- etp /= rpos;
- for (j = 0; j < rneg; j++)
- {
- if (neval[j] >= 0)
- ++fp;
- if (neval[j] >= classifier.threshold)
- ++efp;
- }
- fp /= rneg;
- efp /= rneg;
- PRINT(CCV_CLI_INFO, "stage classifier real TP rate : %f, FP rate : %f\n", tp, fp);
- PRINT(CCV_CLI_INFO, "stage classifier TP rate : %f, FP rate : %f at threshold : %f\n", etp, efp, classifier.threshold);
- if (k > 0)
- {
- /* save classifier state */
- sprintf(buf, "%s/stage-%d.txt", dir, i);
- _ccv_write_bbf_stage_classifier(buf, &classifier);
- sprintf(buf, "%s/stat.txt", dir);
- _ccv_save_bbf_cacade_training_state(buf, i, k, bg, pw, nw, posnum, negnum);
- }
- if (etp > params.pos_crit && efp < params.neg_crit)
- break;
- /* TODO: more post-process is needed in here */
-
- /* select the best feature in current distribution through genetic algorithm optimization */
- ccv_bbf_feature_t best;
- if (params.optimizer == CCV_BBF_GENETIC_OPT)
- {
- best = _ccv_bbf_genetic_optimize(posdata, rpos, negdata, rneg, params.feature_number, cascade->size, pw, nw);
- }
- else if (params.optimizer == CCV_BBF_FLOAT_OPT)
- {
- best = _ccv_bbf_convex_optimize(posdata, rpos, negdata, rneg, 0, cascade->size, pw, nw);
- }
- else
- {
- best = _ccv_bbf_genetic_optimize(posdata, rpos, negdata, rneg, params.feature_number, cascade->size, pw, nw);
- best = _ccv_bbf_convex_optimize(posdata, rpos, negdata, rneg, &best, cascade->size, pw, nw);
- }
- double err = _ccv_bbf_error_rate(&best, posdata, rpos, negdata, rneg, cascade->size, pw, nw);
- double rw = (1 - err) / err;
- totalw = 0;
- /* reweight */
- for (j = 0; j < rpos; j++)
- {
- unsigned char *u8[] = {posdata[j], posdata[j] + isizs0, posdata[j] + isizs01};
- if (!_ccv_run_bbf_feature(&best, steps, u8))
- pw[j] *= rw;
- pw[j] *= params.balance_k;
- totalw += pw[j];
- }
- for (j = 0; j < rneg; j++)
- {
- unsigned char *u8[] = {negdata[j], negdata[j] + isizs0, negdata[j] + isizs01};
- if (_ccv_run_bbf_feature(&best, steps, u8))
- nw[j] *= rw;
- nw[j] *= inv_balance_k;
- totalw += nw[j];
- }
- for (j = 0; j < rpos; j++)
- pw[j] = pw[j] / totalw;
- for (j = 0; j < rneg; j++)
- nw[j] = nw[j] / totalw;
- double c = log(rw);
- PRINT(CCV_CLI_INFO, "coefficient of feature %d: %f\n", k + 1, c);
- classifier.count = k + 1;
- /* resizing classifier */
- if (k >= cacheK)
- {
- ccv_bbf_feature_t *feature = (ccv_bbf_feature_t *)ccmalloc(cacheK * 2 * sizeof(ccv_bbf_feature_t));
- memcpy(feature, classifier.feature, cacheK * sizeof(ccv_bbf_feature_t));
- ccfree(classifier.feature);
- float *alpha = (float *)ccmalloc(cacheK * 4 * sizeof(float));
- memcpy(alpha, classifier.alpha, cacheK * 2 * sizeof(float));
- ccfree(classifier.alpha);
- classifier.feature = feature;
- classifier.alpha = alpha;
- cacheK *= 2;
- }
- /* setup new feature */
- classifier.feature[k] = best;
- classifier.alpha[k * 2] = -c;
- classifier.alpha[k * 2 + 1] = c;
- }
- cascade->count = i + 1;
- ccv_bbf_stage_classifier_t *stage_classifier = (ccv_bbf_stage_classifier_t *)ccmalloc(cascade->count * sizeof(ccv_bbf_stage_classifier_t));
- memcpy(stage_classifier, cascade->stage_classifier, i * sizeof(ccv_bbf_stage_classifier_t));
- ccfree(cascade->stage_classifier);
- stage_classifier[i] = classifier;
- cascade->stage_classifier = stage_classifier;
- k = 0;
- bg = 0;
- for (j = 0; j < rpos; j++)
- ccfree(posdata[j]);
- for (j = 0; j < rneg; j++)
- ccfree(negdata[j]);
- }
-
- ccfree(neval);
- ccfree(peval);
- ccfree(nw);
- ccfree(pw);
- ccfree(negdata);
- ccfree(posdata);
- ccfree(cascade);
-}
-#else
-void ccv_bbf_classifier_cascade_new(ccv_dense_matrix_t **posimg, int posnum, char **bgfiles, int bgnum, int negnum, ccv_size_t size, const char *dir, ccv_bbf_new_param_t params)
-{
- fprintf(stderr, " ccv_bbf_classifier_cascade_new requires libgsl support, please compile ccv with libgsl.\n");
-}
-#endif
-
-static int _ccv_is_equal(const void *_r1, const void *_r2, void *data)
-{
- const ccv_comp_t *r1 = (const ccv_comp_t *)_r1;
- const ccv_comp_t *r2 = (const ccv_comp_t *)_r2;
- int distance = (int)(r1->rect.width * 0.25 + 0.5);
-
- return r2->rect.x <= r1->rect.x + distance &&
- r2->rect.x >= r1->rect.x - distance &&
- r2->rect.y <= r1->rect.y + distance &&
- r2->rect.y >= r1->rect.y - distance &&
- r2->rect.width <= (int)(r1->rect.width * 1.5 + 0.5) &&
- (int)(r2->rect.width * 1.5 + 0.5) >= r1->rect.width;
-}
-
-static int _ccv_is_equal_same_class(const void *_r1, const void *_r2, void *data)
-{
- const ccv_comp_t *r1 = (const ccv_comp_t *)_r1;
- const ccv_comp_t *r2 = (const ccv_comp_t *)_r2;
- int distance = (int)(r1->rect.width * 0.25 + 0.5);
-
- return r2->classification.id == r1->classification.id &&
- r2->rect.x <= r1->rect.x + distance &&
- r2->rect.x >= r1->rect.x - distance &&
- r2->rect.y <= r1->rect.y + distance &&
- r2->rect.y >= r1->rect.y - distance &&
- r2->rect.width <= (int)(r1->rect.width * 1.5 + 0.5) &&
- (int)(r2->rect.width * 1.5 + 0.5) >= r1->rect.width;
-}
-
-ccv_array_t *ccv_bbf_detect_objects(ccv_dense_matrix_t *a, ccv_bbf_classifier_cascade_t **_cascade, int count, ccv_bbf_param_t params)
-{
- int hr = a->rows / params.size.height;
- int wr = a->cols / params.size.width;
- double scale = pow(2., 1. / (params.interval + 1.));
- int next = params.interval + 1;
- int scale_upto = (int)(log((double)ccv_min(hr, wr)) / log(scale));
- ccv_dense_matrix_t **pyr = (ccv_dense_matrix_t **)alloca((scale_upto + next * 2) * 4 * sizeof(ccv_dense_matrix_t *));
- memset(pyr, 0, (scale_upto + next * 2) * 4 * sizeof(ccv_dense_matrix_t *));
- if (params.size.height != _cascade[0]->size.height || params.size.width != _cascade[0]->size.width)
- ccv_resample(a, &pyr[0], 0, a->rows * _cascade[0]->size.height / params.size.height, a->cols * _cascade[0]->size.width / params.size.width, CCV_INTER_AREA);
- else
- pyr[0] = a;
- int i, j, k, t, x, y, q;
- for (i = 1; i < ccv_min(params.interval + 1, scale_upto + next * 2); i++)
- ccv_resample(pyr[0], &pyr[i * 4], 0, (int)(pyr[0]->rows / pow(scale, i)), (int)(pyr[0]->cols / pow(scale, i)), CCV_INTER_AREA);
- for (i = next; i < scale_upto + next * 2; i++)
- ccv_sample_down(pyr[i * 4 - next * 4], &pyr[i * 4], 0, 0, 0);
- if (params.accurate)
- for (i = next * 2; i < scale_upto + next * 2; i++)
- {
- ccv_sample_down(pyr[i * 4 - next * 4], &pyr[i * 4 + 1], 0, 1, 0);
- ccv_sample_down(pyr[i * 4 - next * 4], &pyr[i * 4 + 2], 0, 0, 1);
- ccv_sample_down(pyr[i * 4 - next * 4], &pyr[i * 4 + 3], 0, 1, 1);
- }
- ccv_array_t *idx_seq;
- ccv_array_t *seq = ccv_array_new(sizeof(ccv_comp_t), 64, 0);
- ccv_array_t *seq2 = ccv_array_new(sizeof(ccv_comp_t), 64, 0);
- ccv_array_t *result_seq = ccv_array_new(sizeof(ccv_comp_t), 64, 0);
- /* detect in multi scale */
- for (t = 0; t < count; t++)
- {
- ccv_bbf_classifier_cascade_t *cascade = _cascade[t];
- float scale_x = (float)params.size.width / (float)cascade->size.width;
- float scale_y = (float)params.size.height / (float)cascade->size.height;
- ccv_array_clear(seq);
- for (i = 0; i < scale_upto; i++)
- {
- int dx[] = {0, 1, 0, 1};
- int dy[] = {0, 0, 1, 1};
- int i_rows = pyr[i * 4 + next * 8]->rows - (cascade->size.height >> 2);
- int steps[] = {pyr[i * 4]->step, pyr[i * 4 + next * 4]->step, pyr[i * 4 + next * 8]->step};
- int i_cols = pyr[i * 4 + next * 8]->cols - (cascade->size.width >> 2);
- int paddings[] = {pyr[i * 4]->step * 4 - i_cols * 4,
- pyr[i * 4 + next * 4]->step * 2 - i_cols * 2,
- pyr[i * 4 + next * 8]->step - i_cols};
- for (q = 0; q < (params.accurate ? 4 : 1); q++)
- {
- unsigned char *u8[] = {pyr[i * 4]->data.u8 + dx[q] * 2 + dy[q] * pyr[i * 4]->step * 2, pyr[i * 4 + next * 4]->data.u8 + dx[q] + dy[q] * pyr[i * 4 + next * 4]->step, pyr[i * 4 + next * 8 + q]->data.u8};
- for (y = 0; y < i_rows; y++)
- {
- for (x = 0; x < i_cols; x++)
- {
- float sum;
- int flag = 1;
- ccv_bbf_stage_classifier_t *classifier = cascade->stage_classifier;
- for (j = 0; j < cascade->count; ++j, ++classifier)
- {
- sum = 0;
- float *alpha = classifier->alpha;
- ccv_bbf_feature_t *feature = classifier->feature;
- for (k = 0; k < classifier->count; ++k, alpha += 2, ++feature)
- sum += alpha[_ccv_run_bbf_feature(feature, steps, u8)];
- if (sum < classifier->threshold)
- {
- flag = 0;
- break;
- }
- }
- if (flag)
- {
- ccv_comp_t comp;
- comp.rect = ccv_rect((int)((x * 4 + dx[q] * 2) * scale_x + 0.5), (int)((y * 4 + dy[q] * 2) * scale_y + 0.5), (int)(cascade->size.width * scale_x + 0.5), (int)(cascade->size.height * scale_y + 0.5));
- comp.neighbors = 1;
- comp.classification.id = t;
- comp.classification.confidence = sum;
- ccv_array_push(seq, &comp);
- }
- u8[0] += 4;
- u8[1] += 2;
- u8[2] += 1;
- }
- u8[0] += paddings[0];
- u8[1] += paddings[1];
- u8[2] += paddings[2];
- }
- }
- scale_x *= scale;
- scale_y *= scale;
- }
-
- /* the following code from OpenCV's haar feature implementation */
- if (params.min_neighbors == 0)
- {
- for (i = 0; i < seq->rnum; i++)
- {
- ccv_comp_t *comp = (ccv_comp_t *)ccv_array_get(seq, i);
- ccv_array_push(result_seq, comp);
- }
- }
- else
- {
- idx_seq = 0;
- ccv_array_clear(seq2);
- // group retrieved rectangles in order to filter out noise
- int ncomp = ccv_array_group(seq, &idx_seq, _ccv_is_equal_same_class, 0);
- ccv_comp_t *comps = (ccv_comp_t *)ccmalloc((ncomp + 1) * sizeof(ccv_comp_t));
- memset(comps, 0, (ncomp + 1) * sizeof(ccv_comp_t));
-
- // count number of neighbors
- for (i = 0; i < seq->rnum; i++)
- {
- ccv_comp_t r1 = *(ccv_comp_t *)ccv_array_get(seq, i);
- int idx = *(int *)ccv_array_get(idx_seq, i);
-
- if (comps[idx].neighbors == 0)
- comps[idx].classification.confidence = r1.classification.confidence;
-
- ++comps[idx].neighbors;
-
- comps[idx].rect.x += r1.rect.x;
- comps[idx].rect.y += r1.rect.y;
- comps[idx].rect.width += r1.rect.width;
- comps[idx].rect.height += r1.rect.height;
- comps[idx].classification.id = r1.classification.id;
- comps[idx].classification.confidence = ccv_max(comps[idx].classification.confidence, r1.classification.confidence);
- }
-
- // calculate average bounding box
- for (i = 0; i < ncomp; i++)
- {
- int n = comps[i].neighbors;
- if (n >= params.min_neighbors)
- {
- ccv_comp_t comp;
- comp.rect.x = (comps[i].rect.x * 2 + n) / (2 * n);
- comp.rect.y = (comps[i].rect.y * 2 + n) / (2 * n);
- comp.rect.width = (comps[i].rect.width * 2 + n) / (2 * n);
- comp.rect.height = (comps[i].rect.height * 2 + n) / (2 * n);
- comp.neighbors = comps[i].neighbors;
- comp.classification.id = comps[i].classification.id;
- comp.classification.confidence = comps[i].classification.confidence;
- ccv_array_push(seq2, &comp);
- }
- }
-
- // filter out small face rectangles inside large face rectangles
- for (i = 0; i < seq2->rnum; i++)
- {
- ccv_comp_t r1 = *(ccv_comp_t *)ccv_array_get(seq2, i);
- int flag = 1;
-
- for (j = 0; j < seq2->rnum; j++)
- {
- ccv_comp_t r2 = *(ccv_comp_t *)ccv_array_get(seq2, j);
- int distance = (int)(r2.rect.width * 0.25 + 0.5);
-
- if (i != j &&
- r1.classification.id == r2.classification.id &&
- r1.rect.x >= r2.rect.x - distance &&
- r1.rect.y >= r2.rect.y - distance &&
- r1.rect.x + r1.rect.width <= r2.rect.x + r2.rect.width + distance &&
- r1.rect.y + r1.rect.height <= r2.rect.y + r2.rect.height + distance &&
- (r2.neighbors > ccv_max(3, r1.neighbors) || r1.neighbors < 3))
- {
- flag = 0;
- break;
- }
- }
-
- if (flag)
- ccv_array_push(result_seq, &r1);
- }
- ccv_array_free(idx_seq);
- ccfree(comps);
- }
- }
-
- ccv_array_free(seq);
- ccv_array_free(seq2);
-
- ccv_array_t *result_seq2;
- /* the following code from OpenCV's haar feature implementation */
- if (params.flags & CCV_BBF_NO_NESTED)
- {
- result_seq2 = ccv_array_new(sizeof(ccv_comp_t), 64, 0);
- idx_seq = 0;
- // group retrieved rectangles in order to filter out noise
- int ncomp = ccv_array_group(result_seq, &idx_seq, _ccv_is_equal, 0);
- ccv_comp_t *comps = (ccv_comp_t *)ccmalloc((ncomp + 1) * sizeof(ccv_comp_t));
- memset(comps, 0, (ncomp + 1) * sizeof(ccv_comp_t));
-
- // count number of neighbors
- for (i = 0; i < result_seq->rnum; i++)
- {
- ccv_comp_t r1 = *(ccv_comp_t *)ccv_array_get(result_seq, i);
- int idx = *(int *)ccv_array_get(idx_seq, i);
-
- if (comps[idx].neighbors == 0 || comps[idx].classification.confidence < r1.classification.confidence)
- {
- comps[idx].classification.confidence = r1.classification.confidence;
- comps[idx].neighbors = 1;
- comps[idx].rect = r1.rect;
- comps[idx].classification.id = r1.classification.id;
- }
- }
-
- // calculate average bounding box
- for (i = 0; i < ncomp; i++)
- if (comps[i].neighbors)
- ccv_array_push(result_seq2, &comps[i]);
-
- ccv_array_free(result_seq);
- ccfree(comps);
- }
- else
- {
- result_seq2 = result_seq;
- }
-
- for (i = 1; i < scale_upto + next * 2; i++)
- ccv_matrix_free(pyr[i * 4]);
- if (params.accurate)
- for (i = next * 2; i < scale_upto + next * 2; i++)
- {
- ccv_matrix_free(pyr[i * 4 + 1]);
- ccv_matrix_free(pyr[i * 4 + 2]);
- ccv_matrix_free(pyr[i * 4 + 3]);
- }
- if (params.size.height != _cascade[0]->size.height || params.size.width != _cascade[0]->size.width)
- ccv_matrix_free(pyr[0]);
-
- return result_seq2;
-}
-
-ccv_bbf_classifier_cascade_t *ccv_bbf_read_classifier_cascade(const char *directory)
-{
- char buf[1024];
- sprintf(buf, "%s/cascade.txt", directory);
- int s, i;
- FILE *r = fopen(buf, "r");
- if (r == 0)
- return 0;
- ccv_bbf_classifier_cascade_t *cascade = (ccv_bbf_classifier_cascade_t *)ccmalloc(sizeof(ccv_bbf_classifier_cascade_t));
- s = fscanf(r, "%d %d %d", &cascade->count, &cascade->size.width, &cascade->size.height);
- assert(s > 0);
- cascade->stage_classifier = (ccv_bbf_stage_classifier_t *)ccmalloc(cascade->count * sizeof(ccv_bbf_stage_classifier_t));
- for (i = 0; i < cascade->count; i++)
- {
- sprintf(buf, "%s/stage-%d.txt", directory, i);
- if (_ccv_read_bbf_stage_classifier(buf, &cascade->stage_classifier[i]) < 0)
- {
- cascade->count = i;
- break;
- }
- }
- fclose(r);
- return cascade;
-}
-
-ccv_bbf_classifier_cascade_t *ccv_bbf_classifier_cascade_read_binary(char *s)
-{
- int i;
- ccv_bbf_classifier_cascade_t *cascade = (ccv_bbf_classifier_cascade_t *)ccmalloc(sizeof(ccv_bbf_classifier_cascade_t));
- memcpy(&cascade->count, s, sizeof(cascade->count));
- s += sizeof(cascade->count);
- memcpy(&cascade->size.width, s, sizeof(cascade->size.width));
- s += sizeof(cascade->size.width);
- memcpy(&cascade->size.height, s, sizeof(cascade->size.height));
- s += sizeof(cascade->size.height);
- ccv_bbf_stage_classifier_t *classifier = cascade->stage_classifier = (ccv_bbf_stage_classifier_t *)ccmalloc(cascade->count * sizeof(ccv_bbf_stage_classifier_t));
- for (i = 0; i < cascade->count; i++, classifier++)
- {
- memcpy(&classifier->count, s, sizeof(classifier->count));
- s += sizeof(classifier->count);
- memcpy(&classifier->threshold, s, sizeof(classifier->threshold));
- s += sizeof(classifier->threshold);
- classifier->feature = (ccv_bbf_feature_t *)ccmalloc(classifier->count * sizeof(ccv_bbf_feature_t));
- classifier->alpha = (float *)ccmalloc(classifier->count * 2 * sizeof(float));
- memcpy(classifier->feature, s, classifier->count * sizeof(ccv_bbf_feature_t));
- s += classifier->count * sizeof(ccv_bbf_feature_t);
- memcpy(classifier->alpha, s, classifier->count * 2 * sizeof(float));
- s += classifier->count * 2 * sizeof(float);
- }
- return cascade;
-}
-
-int ccv_bbf_classifier_cascade_write_binary(ccv_bbf_classifier_cascade_t *cascade, char *s, int slen)
-{
- int i;
- int len = sizeof(cascade->count) + sizeof(cascade->size.width) + sizeof(cascade->size.height);
- ccv_bbf_stage_classifier_t *classifier = cascade->stage_classifier;
- for (i = 0; i < cascade->count; i++, classifier++)
- len += sizeof(classifier->count) + sizeof(classifier->threshold) + classifier->count * sizeof(ccv_bbf_feature_t) + classifier->count * 2 * sizeof(float);
- if (slen >= len)
- {
- memcpy(s, &cascade->count, sizeof(cascade->count));
- s += sizeof(cascade->count);
- memcpy(s, &cascade->size.width, sizeof(cascade->size.width));
- s += sizeof(cascade->size.width);
- memcpy(s, &cascade->size.height, sizeof(cascade->size.height));
- s += sizeof(cascade->size.height);
- classifier = cascade->stage_classifier;
- for (i = 0; i < cascade->count; i++, classifier++)
- {
- memcpy(s, &classifier->count, sizeof(classifier->count));
- s += sizeof(classifier->count);
- memcpy(s, &classifier->threshold, sizeof(classifier->threshold));
- s += sizeof(classifier->threshold);
- memcpy(s, classifier->feature, classifier->count * sizeof(ccv_bbf_feature_t));
- s += classifier->count * sizeof(ccv_bbf_feature_t);
- memcpy(s, classifier->alpha, classifier->count * 2 * sizeof(float));
- s += classifier->count * 2 * sizeof(float);
- }
- }
- return len;
-}
-
-void ccv_bbf_classifier_cascade_free(ccv_bbf_classifier_cascade_t *cascade)
-{
- int i;
- for (i = 0; i < cascade->count; ++i)
- {
- ccfree(cascade->stage_classifier[i].feature);
- ccfree(cascade->stage_classifier[i].alpha);
- }
- ccfree(cascade->stage_classifier);
- ccfree(cascade);
-}
\ No newline at end of file
diff --git a/test/source.cs b/test/source.cs
deleted file mode 100644
index b2aad3b..0000000
--- a/test/source.cs
+++ /dev/null
@@ -1,259 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.IO.Compression;
-using System.Runtime.InteropServices;
-using System.Windows.Forms;
-using Microsoft.Win32;
-using Shadowsocks.Controller;
-
-namespace Shadowsocks.Util
-{
- public struct BandwidthScaleInfo
- {
- public float value;
- public string unitName;
- public long unit;
-
- public BandwidthScaleInfo(float value, string unitName, long unit)
- {
- this.value = value;
- this.unitName = unitName;
- this.unit = unit;
- }
- }
-
- public static class Utils
- {
- private static string _tempPath = null;
-
- // return path to store temporary files
- public static string GetTempPath()
- {
- if (_tempPath == null)
- {
- try
- {
- Directory.CreateDirectory(Path.Combine(Application.StartupPath, "ss_win_temp"));
- // don't use "/", it will fail when we call explorer /select xxx/ss_win_temp\xxx.log
- _tempPath = Path.Combine(Application.StartupPath, "ss_win_temp");
- }
- catch (Exception e)
- {
- Logging.Error(e);
- throw;
- }
- }
- return _tempPath;
- }
-
- // return a full path with filename combined which pointed to the temporary directory
- public static string GetTempPath(string filename)
- {
- return Path.Combine(GetTempPath(), filename);
- }
-
- public static void ReleaseMemory(bool removePages)
- {
- // release any unused pages
- // making the numbers look good in task manager
- // this is totally nonsense in programming
- // but good for those users who care
- // making them happier with their everyday life
- // which is part of user experience
- GC.Collect(GC.MaxGeneration);
- GC.WaitForPendingFinalizers();
- if (removePages)
- {
- // as some users have pointed out
- // removing pages from working set will cause some IO
- // which lowered user experience for another group of users
- //
- // so we do 2 more things here to satisfy them:
- // 1. only remove pages once when configuration is changed
- // 2. add more comments here to tell users that calling
- // this function will not be more frequent than
- // IM apps writing chat logs, or web browsers writing cache files
- // if they're so concerned about their disk, they should
- // uninstall all IM apps and web browsers
- //
- // please open an issue if you're worried about anything else in your computer
- // no matter it's GPU performance, monitor contrast, audio fidelity
- // or anything else in the task manager
- // we'll do as much as we can to help you
- //
- // just kidding
- SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle,
- (UIntPtr)0xFFFFFFFF,
- (UIntPtr)0xFFFFFFFF);
- }
- }
-
- public static string UnGzip(byte[] buf)
- {
- byte[] buffer = new byte[1024];
- int n;
- using (MemoryStream sb = new MemoryStream())
- {
- using (GZipStream input = new GZipStream(new MemoryStream(buf),
- CompressionMode.Decompress,
- false))
- {
- while ((n = input.Read(buffer, 0, buffer.Length)) > 0)
- {
- sb.Write(buffer, 0, n);
- }
- }
- return System.Text.Encoding.UTF8.GetString(sb.ToArray());
- }
- }
-
- public static string FormatBandwidth(long n)
- {
- var result = GetBandwidthScale(n);
- return $"{result.value:0.##}{result.unitName}";
- }
-
- public static string FormatBytes(long bytes)
- {
- const long K = 1024L;
- const long M = K * 1024L;
- const long G = M * 1024L;
- const long T = G * 1024L;
- const long P = T * 1024L;
- const long E = P * 1024L;
-
- if (bytes >= P * 990)
- return (bytes / (double)E).ToString("F5") + "EiB";
- if (bytes >= T * 990)
- return (bytes / (double)P).ToString("F5") + "PiB";
- if (bytes >= G * 990)
- return (bytes / (double)T).ToString("F5") + "TiB";
- if (bytes >= M * 990)
- {
- return (bytes / (double)G).ToString("F4") + "GiB";
- }
- if (bytes >= M * 100)
- {
- return (bytes / (double)M).ToString("F1") + "MiB";
- }
- if (bytes >= M * 10)
- {
- return (bytes / (double)M).ToString("F2") + "MiB";
- }
- if (bytes >= K * 990)
- {
- return (bytes / (double)M).ToString("F3") + "MiB";
- }
- if (bytes > K * 2)
- {
- return (bytes / (double)K).ToString("F1") + "KiB";
- }
- return bytes.ToString() + "B";
- }
-
- ///
- /// Return scaled bandwidth
- ///
- /// Raw bandwidth
- ///
- /// The BandwidthScaleInfo struct
- ///
- public static BandwidthScaleInfo GetBandwidthScale(long n)
- {
- long scale = 1;
- float f = n;
- string unit = "B";
- if (f > 1024)
- {
- f = f / 1024;
- scale <<= 10;
- unit = "KiB";
- }
- if (f > 1024)
- {
- f = f / 1024;
- scale <<= 10;
- unit = "MiB";
- }
- if (f > 1024)
- {
- f = f / 1024;
- scale <<= 10;
- unit = "GiB";
- }
- if (f > 1024)
- {
- f = f / 1024;
- scale <<= 10;
- unit = "TiB";
- }
- return new BandwidthScaleInfo(f, unit, scale);
- }
-
- public static RegistryKey OpenRegKey(string name, bool writable, RegistryHive hive = RegistryHive.CurrentUser)
- {
- // we are building x86 binary for both x86 and x64, which will
- // cause problem when opening registry key
- // detect operating system instead of CPU
- if (name.IsNullOrEmpty()) throw new ArgumentException(nameof(name));
- try
- {
- RegistryKey userKey = RegistryKey.OpenBaseKey(hive,
- Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32)
- .OpenSubKey(name, writable);
- return userKey;
- }
- catch (ArgumentException ae)
- {
- MessageBox.Show("OpenRegKey: " + ae.ToString());
- return null;
- }
- catch (Exception e)
- {
- Logging.LogUsefulException(e);
- return null;
- }
- }
-
- public static bool IsWinVistaOrHigher()
- {
- return Environment.OSVersion.Version.Major > 5;
- }
-
- [DllImport("kernel32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool SetProcessWorkingSetSize(IntPtr process,
- UIntPtr minimumWorkingSetSize, UIntPtr maximumWorkingSetSize);
-
-
- // See: https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx
- public static bool IsSupportedRuntimeVersion()
- {
- /*
- * +-----------------------------------------------------------------+----------------------------+
- * | Version | Value of the Release DWORD |
- * +-----------------------------------------------------------------+----------------------------+
- * | .NET Framework 4.6.2 installed on Windows 10 Anniversary Update | 394802 |
- * | .NET Framework 4.6.2 installed on all other Windows OS versions | 394806 |
- * +-----------------------------------------------------------------+----------------------------+
- */
- const int minSupportedRelease = 394802;
-
- const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
- using (var ndpKey = OpenRegKey(subkey, false, RegistryHive.LocalMachine))
- {
- if (ndpKey?.GetValue("Release") != null)
- {
- var releaseKey = (int)ndpKey.GetValue("Release");
-
- if (releaseKey >= minSupportedRelease)
- {
- return true;
- }
- }
- }
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/test/source.css b/test/source.css
deleted file mode 100644
index 8214563..0000000
--- a/test/source.css
+++ /dev/null
@@ -1,61 +0,0 @@
-
-body {
- font-family: arial;
-}
-
-h1, p, table {
- background-color:#CCC;
- border: 1px solid;
- color:#39F;
- text-align: center;
- width: 100%;
-}
-
-.addon-store .pagehead h1
-.addon-store .addon-summary:after { clear: both }
-
-#addon-store .pagehead .electrocat-small {
- bottom: -7px;
- position: absolute;
- right: 0;
-}
-
-.addon-store .addons-nav a.selected {
- border-bottom-color: #d26911;
- color: #333;
- font-weight: bold;
- padding: 0 0 14px;
-}
-
-.addon-store .addon-icon {
- background: #fff;
- border: 1px solid #ddd;
- box-shadow: 0 1px 2px rgba(0,0,0,0.15);
- float: left;
- height: 80px;
- margin-right: 14px;
- width: 80px;
-}
-
-.addon-store .developer-callout {
- background-color: #f1f1f1;
- background-image: -moz-linear-gradient(#fafafa, #f1f1f1);
- background-image: -webkit-linear-gradient(#fafafa, #f1f1f1);
- background-image: linear-gradient(#fafafa, #f1f1f1);
- background-repeat: repeat-x;
- border: 1px solid #ddd;
- border-bottom: 1px solid #ccc;
- border-radius: 3px;
- box-shadow: inset 0 1px 0 #fff, 0 1px 5px #f1f1f1;
- margin-top: 40px;
- text-shadow: 0 1px 0 #fff;
-}
-
-.addon-field-editor .addon-field-list, .addon-field-editor .addon-new-field {
- -moz-box-sizing: border-box;
- border-radius: 3px;
- box-sizing: border-box;
- display: inline-block;
- text-align: center;
- width: 595px;
-}
\ No newline at end of file
diff --git a/test/source.csx b/test/source.csx
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.d b/test/source.d
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.dart b/test/source.dart
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.do b/test/source.do
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.dot b/test/source.dot
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.erl b/test/source.erl
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.ex b/test/source.ex
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.go b/test/source.go
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.gql b/test/source.gql
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.gradle b/test/source.gradle
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.graphql b/test/source.graphql
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.groovy b/test/source.groovy
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.h b/test/source.h
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.haml b/test/source.haml
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.hs b/test/source.hs
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.html b/test/source.html
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.html.eex b/test/source.html.eex
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.hx b/test/source.hx
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.jade b/test/source.jade
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.java b/test/source.java
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.jl b/test/source.jl
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.json b/test/source.json
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.jsp b/test/source.jsp
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.jsx b/test/source.jsx
deleted file mode 100644
index 8337712..0000000
--- a/test/source.jsx
+++ /dev/null
@@ -1 +0,0 @@
-//
diff --git a/test/source.less b/test/source.less
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.liquid b/test/source.liquid
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.lisp b/test/source.lisp
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.lsl b/test/source.lsl
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.lua b/test/source.lua
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.m b/test/source.m
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.matlab b/test/source.matlab
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.mjs b/test/source.mjs
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.ml b/test/source.ml
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.mustache b/test/source.mustache
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.note b/test/source.note
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.pcss b/test/source.pcss
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.php b/test/source.php
deleted file mode 100644
index c20c54a..0000000
--- a/test/source.php
+++ /dev/null
@@ -1,57 +0,0 @@
-edible = $edible;
- $this->color = $color;
- }
-
- function is_edible()
- {
- return $this->edible;
- }
-
- function what_color()
- {
- return $this->color;
- }
-
-} // end of class Vegetable
-
-// extends the base class
-class Spinach extends Vegetable {
-
-
- var $cooked = false;
-
- function Spinach()
- {
- $this->Vegetable(true, "green");
- }
-
- function cook_it()
- {
- $this->cooked = true;
- }
-
- function is_cooked()
- {
- return $this->cooked;
- }
-
-} // end of class Spinach
-
-?>
-
diff --git a/test/source.pl b/test/source.pl
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.postcss b/test/source.postcss
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.pp b/test/source.pp
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.pug b/test/source.pug
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.py b/test/source.py
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.r b/test/source.r
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.rails b/test/source.rails
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.rb b/test/source.rb
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.re b/test/source.re
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.rei b/test/source.rei
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.rs b/test/source.rs
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.sass b/test/source.sass
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.scala b/test/source.scala
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.scss b/test/source.scss
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.slim b/test/source.slim
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.sql b/test/source.sql
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.styl b/test/source.styl
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.swift b/test/source.swift
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.swig b/test/source.swig
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.tex b/test/source.tex
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.ts b/test/source.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.twig b/test/source.twig
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.vue b/test/source.vue
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.xaml b/test/source.xaml
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.xml b/test/source.xml
deleted file mode 100644
index e69de29..0000000
diff --git a/test/source.yml b/test/source.yml
deleted file mode 100644
index e69de29..0000000
diff --git a/test/src.module.ts b/test/src.module.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/test/src.pipe.ts b/test/src.pipe.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/test/src.resolver.ts b/test/src.resolver.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/test/src.service.ts b/test/src.service.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/test/sublime.sublime-settings b/test/sublime.sublime-settings
deleted file mode 100644
index e69de29..0000000
diff --git a/test/text.md b/test/text.md
deleted file mode 100644
index e69de29..0000000
diff --git a/test/text.txt b/test/text.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/test/windows.bat b/test/windows.bat
deleted file mode 100644
index e69de29..0000000
diff --git a/test/windows.cmd b/test/windows.cmd
deleted file mode 100644
index e69de29..0000000
diff --git a/test/yarn.lock b/test/yarn.lock
deleted file mode 100644
index e69de29..0000000
diff --git a/ui/settings.css b/ui/settings.css
new file mode 100644
index 0000000..2e465f8
--- /dev/null
+++ b/ui/settings.css
@@ -0,0 +1,4 @@
+.AccentsRadioContainer > div {
+ display: inline-block;
+ margin-right: 10px;
+}
diff --git a/ui/settings.html b/ui/settings.html
new file mode 100644
index 0000000..bf2b633
--- /dev/null
+++ b/ui/settings.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+ Material Theme Settings Editor
+
+
+
+
+
+
+ Material Theme Settings Editor (preview)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/yarn.lock b/yarn.lock
index fc91e7a..188e855 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4306,7 +4306,7 @@ right-align@^0.1.1:
dependencies:
align-text "^0.1.1"
-rimraf@2, rimraf@2.6.2, rimraf@^2.6.1:
+rimraf@2, rimraf@^2.6.1:
version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
dependencies: