Last active
May 30, 2018 19:07
-
-
Save iandees/f773749c47d088705199 to your computer and use it in GitHub Desktop.
Revisions
-
iandees revised this gist
Jan 2, 2015 . 1 changed file with 29 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -71,5 +71,33 @@ After a day or two figuring out how to compile the examples, I finally made some dlib/examples/build/train_object_detector -tv signs.xml ``` This will run some processing tasks to build the model based on your XML file and then it will test the model against the images you gave it. If the model is excellent, it will match 100% of the original bounding boxes. The output below has 100% recall indicated by the `1 1 1`: ```bash Saving trained detector to object_detector.svm Testing detector on training data... Test detector (precision,recall,AP): 1 1 1 Parameters used: threads: 4 C: 1 eps: 0.01 target-size: 5000 detection window width: 65 detection window height: 77 upsample this many times : 0 ``` Your model is now stored in the `object_detector.svm` file and can be used to predict the location of similar objects in completely new images. ### Detect signs in new images 1. Find an image that you didn't train with. Run the object detector again with the new image specified as an argument: ```bash dlib/examples/build/train_object_detector Downloads/new_sign_image.jpg ``` This time around the program will use the model you trained to highlight any objects on an XWindows/XQuartz window with the image as a background:  -
iandees revised this gist
Jan 2, 2015 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,7 +58,18 @@ After a day or two figuring out how to compile the examples, I finally made some ``` 4. This will open a window via XWindows/XQuartz:  Now, for each image you hold down <kbd>Shift</kbd> and drag a bounding box around the object to detect. As in the screenshot here, I found that selecting the region immediately inside the black border of the sign resulted in a better model. If you accidentally create a bounding box that you didn't want, double click the border of the bounding box and press <kbd>Delete</kbd>. There are more interface details in the Help menu. 5. When you finish highlighting the regions of interest, save the changes (File -> Save) and exit the `imglab` tool. Your XML file now contains extra markup that specifies the bounding boxes for the objects of interest. 6. Next, we'll use the XML file you created to train a classifier: ```bash dlib/examples/build/train_object_detector -tv signs.xml ``` This will run some processing -
iandees revised this gist
Jan 2, 2015 . 1 changed file with 38 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,30 +14,51 @@ After a day or two figuring out how to compile the examples, I finally made some 2. Install the `libjpeg` dependency: ```bash brew install libjpeg ``` 3. As of this writing, `dlib` won't compile due to weirdness with the system-installed `libjpeg`, so the [developer suggests](https://sourceforge.net/p/dclib/discussion/442518/thread/bdccfe1a/#2aed/b0ad) modifying line 277 of `dlib/CMakeLists.txt` to look like this: ``` if (JPEG_FOUND AND LIBJPEG_IS_GOOD AND NOT APPLE) ``` 4. Compile the example programs that come with `dlib` (one of which is the classifier training program): ```bash mkdir dlib/examples/build cd dlib/examples/build cmake .. cmake --build . ``` 5. You'll also want to compile the `imglab` tool so you can mark up images to tell the system what you're searching for: ```bash mkdir dlib/tools/imglab/build cd dlib/tools/imglab/build cmake --build . ``` ### Train a classifier for road signs 1. Download at least a dozen images that contain the object you're trying to recognize. For road signs I used [Wikimedia commons](http://commons.wikimedia.org/wiki/File:Speed_Limit_65_sign.svg), [Mapillary](http://www.mapillary.com/map/im/BGvdxqQ8u-appilby6DACg), or a Google Image Search. Put these images in one directory on your computer. I found that they all had to be converted to JPEG (and I used `convert` from ImageMagick to do it) for the next step. 2. Run the `imglab` tool once to create an XML list of files you downloaded: ```bash dlib/tools/imglab/build/imglab -c signs.xml Downloads/sign*.jpg ``` 3. The file that `imglab` just created is a very simple XML file that lists relative paths for all the images. The next step is to specify where the objects are in the images. Run the `imglab` tool once more, but this time only specify the XML file you created above: ```bash dlib/tools/imglab/build/imglab signs.xml ``` 4. This will open a window via XWindows/XQuartz:  The -
iandees revised this gist
Jan 2, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,9 +8,9 @@ After a day or two figuring out how to compile the examples, I finally made some 1. Clone [`dlib`](https://github.com/davisking/dlib/) from Github to your local machine: ```bash git clone [email protected]:davisking/dlib.git ``` 2. Install the `libjpeg` dependency: -
iandees created this gist
Jan 1, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@  I've been interested in computer vision for a long time, but I haven't had any free time to make any progress until this holiday season. Over Christmas and the New Years I experimented with various methodologies in [OpenCV](http://opencv.org/) to detect road signs and other objects of interest to OpenStreetMap. After some failed experiments with thresholding and [feature detection](http://docs.opencv.org/doc/user_guide/ug_traincascade.html), the excellent [/r/computervision](http://www.reddit.com/r/computervision/) suggested using the [dlib C++ module](http://dlib.net/) because it has more consistently-good documentation and the pre-built tools are faster. After a day or two figuring out how to compile the examples, I finally made some progress: ### Compiling dlib C++ on a Mac with Homebrew 1. Clone [`dlib`](https://github.com/davisking/dlib/) from Github to your local machine: ```bash git clone [email protected]:davisking/dlib.git ``` 2. Install the `libjpeg` dependency: ```bash brew install libjpeg ``` 3. As of this writing, `dlib` won't compile due to weirdness with the system-installed `libjpeg`, so the [developer suggests](https://sourceforge.net/p/dclib/discussion/442518/thread/bdccfe1a/#2aed/b0ad) modifying line 277 of `dlib/CMakeLists.txt` to look like this: ``` if (JPEG_FOUND AND LIBJPEG_IS_GOOD AND NOT APPLE) ``` 4. Compile the example programs that come with `dlib` (one of which is the classifier training program): ```bash mkdir dlib/examples/build cd dlib/examples/build cmake .. cmake --build . ``` 5. You'll also want to compile the `imglab` tool so you can mark up images to tell the system what you're searching for: ```bash mkdir dlib/examples/build cd dlib/tools/imglab/build cmake --build . ```