Skip to content

Commit

Permalink
Fix #16
Browse files Browse the repository at this point in the history
  • Loading branch information
shrubb committed Dec 10, 2016
1 parent e8564f4 commit c0b7267
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ brew install protobuf
luarocks install loadcaffe
```

In Linux you have to build OpenCV3 manually. Follow the instructions in
In Linux you have to build OpenCV 3 manually. Follow the instructions in

* https://github.com/VisionLabs/torch-opencv
* https://github.com/szagoruyko/loadcaffe
Expand All @@ -39,9 +39,11 @@ to predict age and gender of the faces that it finds with a simple cascade detec

Run as
```
th demo.lua `locate haarcascade_frontalface_default.xml`
th demo.lua video_source [path-to-'haarcascade_frontalface_default.xml']
```

Where `video_source` is `camera` or path to a video file, and the second argument is optional.

IMAGINE Lab gives an example:

![age&gender](https://cloud.githubusercontent.com/assets/4953728/12299217/fc819f80-ba15-11e5-95de-653c9fda9b83.png)
Expand Down
12 changes: 9 additions & 3 deletions age_gender/demo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ require 'loadcaffe'

if not arg[1] then
print[[
Usage: th demo.lua video_source
Usage: th demo.lua video_source [path-to-'haarcascade_frontalface_default.xml']
Where
* video_source:
Video source to capture.
If "camera", then default camera is used.
Otherwise, `video_source` is assumed to be a path to a video file.
* path-to-'haarcascade_frontalface_default.xml':
Optional argument, path to OpenCV's haarcascade_frontalface_default.xml.
Use it if your `locate` command isn't able to find it it automatically.
]]
os.exit(-1)
end
Expand All @@ -25,9 +30,10 @@ print('Looking for '..XMLTarget..'...')
local command = io.popen('locate '..XMLTarget, 'r')
local locateOutput = command:read()
local _, endIndex = locateOutput:find(XMLTarget)
local detectorParamsFile = locateOutput:sub(1, endIndex)
local detectorParamsFile = locateOutput:sub(1, endIndex) or arg[2]
command:close()
assert(paths.filep(detectorParamsFile), XMLTarget..' not found!')
assert(paths.filep(detectorParamsFile),
XMLTarget..' not found! Try using the second cmdline argument')

local face_cascade = cv.CascadeClassifier{detectorParamsFile}

Expand Down

0 comments on commit c0b7267

Please sign in to comment.