Skip to content

Commit

Permalink
initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded committed May 22, 2016
1 parent 5a63913 commit 637a12d
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
*.exe
*.out
*.app

*.pyc
build/
44 changes: 44 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
os: linux
language: python
sudo: required
services:
- docker
env:
global:
- CONAN_UPLOAD: 1
- CONAN_REFERENCE: "ZMQ/4.1.1"
- CONAN_USERNAME: "memsharded"
- CONAN_CHANNEL: "testing"
- CONAN_TOTAL_PAGES: 1
matrix:
- CONAN_GCC_VERSIONS: 4.8 CONAN_USE_DOCKER=1
- CONAN_GCC_VERSIONS: 4.9 CONAN_USE_DOCKER=1
- CONAN_GCC_VERSIONS: 5.2 CONAN_USE_DOCKER=1
- CONAN_GCC_VERSIONS: 5.3 CONAN_USE_DOCKER=1

matrix:
include:
- os: osx
osx_image: xcode7.3 # apple-clang 7.3
language: generic
env: CONAN_CURRENT_PAGE=1
- os: osx
osx_image: xcode7.1 # apple-clang 7.0
language: generic
env: CONAN_CURRENT_PAGE=1
- os: osx
osx_image: xcode6.4 # apple-clang 6.1
language: generic
env: CONAN_CURRENT_PAGE=1
- os: osx
osx_image: xcode6.2 # apple-clang 6.0
language: generic
env: CONAN_CURRENT_PAGE=1

install:
- chmod +x .travis/install.sh
- ./.travis/install.sh

script:
- chmod +x .travis/run.sh
- ./.travis/run.sh
23 changes: 23 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e
set -x

if [[ "$(uname -s)" == 'Darwin' ]]; then
brew update || brew update
brew outdated pyenv || brew upgrade pyenv
brew install pyenv-virtualenv
brew install cmake || true

if which pyenv > /dev/null; then
eval "$(pyenv init -)"
fi

pyenv install 2.7.10
pyenv virtualenv 2.7.10 conan
pyenv rehash
pyenv activate conan
fi

pip install conan_package_tools # It install conan too
conan user
13 changes: 13 additions & 0 deletions .travis/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e
set -x

if [[ "$(uname -s)" == 'Darwin' ]]; then
if which pyenv > /dev/null; then
eval "$(pyenv init -)"
fi
pyenv activate conan
fi

python build.py
37 changes: 37 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
build: false
environment:
PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.8"
PYTHON_ARCH: "32"

CONAN_UPLOAD: 1
CONAN_REFERENCE: "ZMQ/4.1.1"
CONAN_USERNAME: "memsharded"
CONAN_CHANNEL: "testing"
CONAN_TOTAL_PAGES: 16

matrix:
- CONAN_CURRENT_PAGE: 1
- CONAN_CURRENT_PAGE: 2
- CONAN_CURRENT_PAGE: 3
- CONAN_CURRENT_PAGE: 4
- CONAN_CURRENT_PAGE: 5
- CONAN_CURRENT_PAGE: 6
- CONAN_CURRENT_PAGE: 7
- CONAN_CURRENT_PAGE: 8
- CONAN_CURRENT_PAGE: 9
- CONAN_CURRENT_PAGE: 10
- CONAN_CURRENT_PAGE: 11
- CONAN_CURRENT_PAGE: 12
- CONAN_CURRENT_PAGE: 13
- CONAN_CURRENT_PAGE: 14
- CONAN_CURRENT_PAGE: 15
- CONAN_CURRENT_PAGE: 16

install:
- set PATH=%PATH%;%PYTHON%/Scripts/
- pip.exe install conan_package_tools # It install conan too
- conan user # It creates the conan data directory

test_script:
- python build.py
7 changes: 7 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from conan.packager import ConanMultiPackager


if __name__ == "__main__":
builder = ConanMultiPackager(username="memsharded", channel="testing")
builder.add_common_builds(shared_option_name="ZMQ:shared")
builder.run()
41 changes: 41 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from conans import ConanFile, CMake, tools
import os


class OpenCVConan(ConanFile):
name = "OpenCV"
version = "2.4.13"
license = "LGPL"
url = "https://github.com/memsharded/conan-opencv.git"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = "shared=False"

def source(self):
tools.download("https://github.com/Itseez/opencv/archive/2.4.13.zip", "opencv.zip")
tools.unzip("opencv.zip")
os.unlink("opencv.zip")

def build(self):
cmake = CMake(self.settings)
os.makedirs("build")
cmake_flags=" -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DBUILD_TESTS=OFF -DBUILD_opencv_apps=OFF -DBUILD_PERF_TESTS=OFF"
self.run('cd build && cmake ../opencv-%s %s %s' % (self.version, cmake_flags, cmake.command_line))
self.run("cd build && cmake --build . %s" % cmake.build_config)

def package(self):
self.copy("*.h*", "include", "opencv-%s/include" % self.version)
for lib in ["core", "calib3d", "contrib", "features2d", "flann", "gpu", "highgui", "imgproc", "legacy", "ml",
"nonfree", "objdetect", "ocl", "photo", "stitching", "superres", "ts", "video", "videstab"]:
self.copy("*.h*", "include", "opencv-%s/modules/%s/include" % (self.version, lib))
self.copy("*.lib", "lib", "build/lib", keep_path=False)
self.copy("*.a", "lib", "build/lib", keep_path=False) # Linux
self.copy("*.dll", "bin", "bin", keep_path=False)
self.copy("*.dylib", "lib", "lib", keep_path=False)
self.copy("*.so", "lib", "lib", keep_path=False) # Linux

def package_info(self):
for lib in ["core", "calib3d", "contrib", "features2d", "flann", "gpu", "highgui", "imgproc", "legacy", "ml",
"nonfree", "objdetect", "ocl", "photo", "stitching", "superres", "ts", "video", "videostab"]:
self.cpp_info.libs.append("opencv_%s%s" % (lib, self.version.replace(".", "")))

8 changes: 8 additions & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PROJECT(LenaFace)
cmake_minimum_required(VERSION 2.8.12)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
CONAN_BASIC_SETUP()

ADD_EXECUTABLE(lena lena.cpp)
TARGET_LINK_LIBRARIES(lena ${CONAN_LIBS})
23 changes: 23 additions & 0 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from conans import ConanFile, CMake
import os

channel = os.getenv("CONAN_CHANNEL", "testing")
username = os.getenv("CONAN_USERNAME", "memsharded")

class ZMQTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
requires = "OpenCV/2.4.13@%s/%s" % (username, channel)
generators = "cmake"

def build(self):
cmake = CMake(self.settings)
self.run('cmake "%s" %s' % (self.conanfile_directory, cmake.command_line))
self.run("cmake --build . %s" % cmake.build_config)

def imports(self):
self.copy("*.dll", "bin", "bin")
self.copy("*.dylib", "bin", "lib")

def test(self):
os.chdir("bin")
server = ".%slena" % os.sep
74 changes: 74 additions & 0 deletions test_package/lena.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

/** Function Headers */
void detectAndDisplay( Mat frame );

/** Global variables */
String face_cascade_name = "haarcascade_frontalface_alt.xml";
String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
CascadeClassifier face_cascade;
CascadeClassifier eyes_cascade;
string window_name = "Capture - Face detection";
RNG rng(12345);

/** @function main */
int main( int argc, const char** argv ){
CvCapture* capture;

//-- 1. Load the cascades
if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };

// Read the image file
Mat frame = imread("diego/opencvex/lena.jpg");
// Apply the classifier to the frame
if (!frame.empty())
detectAndDisplay(frame);
else{
printf(" --(!) No captured frame -- Break!");
}

int c = waitKey();

return 0;
}

void detectAndDisplay( Mat frame ){
std::vector<Rect> faces;
Mat frame_gray;

cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
equalizeHist( frame_gray, frame_gray );

//-- Detect faces
face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(30, 30));

for( size_t i = 0; i < faces.size(); i++ )
{
Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );

Mat faceROI = frame_gray( faces[i] );
std::vector<Rect> eyes;

//-- In each face, detect eyes
eyes_cascade.detectMultiScale(faceROI, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(30, 30));

for( size_t j = 0; j < eyes.size(); j++ )
{
Point center( faces[i].x + eyes[j].x + eyes[j].width*0.5, faces[i].y + eyes[j].y + eyes[j].height*0.5 );
int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
circle( frame, center, radius, Scalar( 255, 0, 0 ), 4, 8, 0 );
}
}
//-- Show what you got
imshow( window_name, frame );
}
Binary file added test_package/lena.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 637a12d

Please sign in to comment.