From c4b39ef571baa2f1df32cd6a396b6b3debb76c7a Mon Sep 17 00:00:00 2001 From: Mattia Astorino Date: Thu, 31 May 2018 10:41:31 +0200 Subject: [PATCH] chore: Move out test folder --- test/--.tmcolor | 79 -- test/.gitignore | 0 test/Dockerfile | 0 test/LICENSE | 0 test/Procfile | 0 test/TODO | 0 test/adobe.ai | 0 test/adobe.as | 0 test/adobe.cfc | 0 test/adobe.cfm | 0 test/adobe.pdf | 0 test/adobe.psb | 0 test/adobe.psd | 0 test/angular.ng.html | 0 test/archive.7z | 0 test/archive.7zip | 0 test/archive.gz | 0 test/archive.pzip | 0 test/archive.rar | 0 test/archive.tar | 0 test/archive.tgz | 0 test/archive.wim | 0 test/archive.zip | 0 test/audio.mp3 | 1 - test/audio.wma | 0 test/binary.tga | 0 test/bower.json | 0 test/component.ts | 0 test/font.eot | 0 test/font.otf | 0 test/font.ttf | 0 test/font.woff | 0 test/image.jpg | 0 test/image.svg | 0 test/package-lock.json | 0 test/package.json | 0 test/settings.ini | 0 test/shell.bash | 2 - test/shell.fish | 0 test/shell.sh | 2 - test/sketch.sketch | 0 test/source.applescript | 0 test/source.asa | 0 test/source.ascx | 0 test/source.asp | 0 test/source.aspx | 0 test/source.blade | 0 test/source.blade.php | 0 test/source.c | 60 -- test/source.c++ | 91 -- test/source.cc | 60 -- test/source.clj | 0 test/source.coffee | 0 test/source.cpp | 1582 --------------------------------- test/source.cs | 259 ------ test/source.css | 61 -- test/source.csx | 0 test/source.d | 0 test/source.dart | 0 test/source.do | 0 test/source.dot | 0 test/source.erl | 0 test/source.ex | 0 test/source.go | 0 test/source.gql | 0 test/source.gradle | 0 test/source.graphql | 0 test/source.groovy | 0 test/source.h | 0 test/source.haml | 0 test/source.hs | 0 test/source.html | 0 test/source.html.eex | 0 test/source.hx | 0 test/source.jade | 0 test/source.java | 0 test/source.jl | 0 test/source.json | 0 test/source.jsp | 0 test/source.jsx | 1 - test/source.less | 0 test/source.liquid | 0 test/source.lisp | 0 test/source.lsl | 0 test/source.lua | 0 test/source.m | 0 test/source.matlab | 0 test/source.mjs | 0 test/source.ml | 0 test/source.mustache | 0 test/source.note | 0 test/source.pcss | 0 test/source.php | 57 -- test/source.pl | 0 test/source.postcss | 0 test/source.pp | 0 test/source.pug | 0 test/source.py | 0 test/source.r | 0 test/source.rails | 0 test/source.rb | 0 test/source.re | 0 test/source.rei | 0 test/source.rs | 0 test/source.sass | 0 test/source.scala | 0 test/source.scss | 0 test/source.slim | 0 test/source.sql | 0 test/source.styl | 0 test/source.swift | 0 test/source.swig | 0 test/source.tex | 0 test/source.ts | 0 test/source.twig | 0 test/source.vue | 0 test/source.xaml | 0 test/source.xml | 0 test/source.yml | 0 test/src.module.ts | 0 test/src.pipe.ts | 0 test/src.resolver.ts | 0 test/src.service.ts | 0 test/sublime.sublime-settings | 0 test/text.md | 0 test/text.txt | 0 test/windows.bat | 0 test/windows.cmd | 0 test/yarn.lock | 0 129 files changed, 2255 deletions(-) delete mode 100644 test/--.tmcolor delete mode 100755 test/.gitignore delete mode 100644 test/Dockerfile delete mode 100644 test/LICENSE delete mode 100644 test/Procfile delete mode 100644 test/TODO delete mode 100644 test/adobe.ai delete mode 100644 test/adobe.as delete mode 100644 test/adobe.cfc delete mode 100644 test/adobe.cfm delete mode 100644 test/adobe.pdf delete mode 100644 test/adobe.psb delete mode 100644 test/adobe.psd delete mode 100644 test/angular.ng.html delete mode 100644 test/archive.7z delete mode 100644 test/archive.7zip delete mode 100644 test/archive.gz delete mode 100644 test/archive.pzip delete mode 100644 test/archive.rar delete mode 100644 test/archive.tar delete mode 100644 test/archive.tgz delete mode 100644 test/archive.wim delete mode 100644 test/archive.zip delete mode 100644 test/audio.mp3 delete mode 100644 test/audio.wma delete mode 100644 test/binary.tga delete mode 100644 test/bower.json delete mode 100644 test/component.ts delete mode 100644 test/font.eot delete mode 100644 test/font.otf delete mode 100644 test/font.ttf delete mode 100644 test/font.woff delete mode 100644 test/image.jpg delete mode 100644 test/image.svg delete mode 100644 test/package-lock.json delete mode 100644 test/package.json delete mode 100644 test/settings.ini delete mode 100644 test/shell.bash delete mode 100644 test/shell.fish delete mode 100644 test/shell.sh delete mode 100644 test/sketch.sketch delete mode 100644 test/source.applescript delete mode 100644 test/source.asa delete mode 100644 test/source.ascx delete mode 100644 test/source.asp delete mode 100644 test/source.aspx delete mode 100644 test/source.blade delete mode 100644 test/source.blade.php delete mode 100644 test/source.c delete mode 100644 test/source.c++ delete mode 100644 test/source.cc delete mode 100644 test/source.clj delete mode 100644 test/source.coffee delete mode 100644 test/source.cpp delete mode 100644 test/source.cs delete mode 100644 test/source.css delete mode 100644 test/source.csx delete mode 100644 test/source.d delete mode 100644 test/source.dart delete mode 100644 test/source.do delete mode 100644 test/source.dot delete mode 100644 test/source.erl delete mode 100644 test/source.ex delete mode 100644 test/source.go delete mode 100644 test/source.gql delete mode 100644 test/source.gradle delete mode 100644 test/source.graphql delete mode 100644 test/source.groovy delete mode 100644 test/source.h delete mode 100644 test/source.haml delete mode 100644 test/source.hs delete mode 100644 test/source.html delete mode 100644 test/source.html.eex delete mode 100644 test/source.hx delete mode 100644 test/source.jade delete mode 100644 test/source.java delete mode 100644 test/source.jl delete mode 100644 test/source.json delete mode 100644 test/source.jsp delete mode 100644 test/source.jsx delete mode 100644 test/source.less delete mode 100644 test/source.liquid delete mode 100644 test/source.lisp delete mode 100644 test/source.lsl delete mode 100644 test/source.lua delete mode 100644 test/source.m delete mode 100644 test/source.matlab delete mode 100644 test/source.mjs delete mode 100644 test/source.ml delete mode 100644 test/source.mustache delete mode 100644 test/source.note delete mode 100644 test/source.pcss delete mode 100644 test/source.php delete mode 100644 test/source.pl delete mode 100644 test/source.postcss delete mode 100644 test/source.pp delete mode 100644 test/source.pug delete mode 100644 test/source.py delete mode 100644 test/source.r delete mode 100644 test/source.rails delete mode 100644 test/source.rb delete mode 100644 test/source.re delete mode 100644 test/source.rei delete mode 100644 test/source.rs delete mode 100644 test/source.sass delete mode 100644 test/source.scala delete mode 100644 test/source.scss delete mode 100644 test/source.slim delete mode 100644 test/source.sql delete mode 100644 test/source.styl delete mode 100644 test/source.swift delete mode 100644 test/source.swig delete mode 100644 test/source.tex delete mode 100644 test/source.ts delete mode 100644 test/source.twig delete mode 100644 test/source.vue delete mode 100644 test/source.xaml delete mode 100644 test/source.xml delete mode 100644 test/source.yml delete mode 100644 test/src.module.ts delete mode 100644 test/src.pipe.ts delete mode 100644 test/src.resolver.ts delete mode 100644 test/src.service.ts delete mode 100644 test/sublime.sublime-settings delete mode 100644 test/text.md delete mode 100644 test/text.txt delete mode 100644 test/windows.bat delete mode 100644 test/windows.cmd delete mode 100644 test/yarn.lock 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