forked from liuliu/ccv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated getting started, and make sure all referenced code compiles, …
…will add these to CI later
- Loading branch information
Showing
9 changed files
with
126 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Title: Include Code Tag for Jekyll | ||
# Author: Brandon Mathis http://brandonmathis.com | ||
# Description: Import files on your filesystem into any blog post as embedded code snippets with syntax highlighting and a download link. | ||
# Configuration: You can set default import path in _config.yml (defaults to code_dir: downloads/code) | ||
# | ||
# Syntax {% include_code path/to/file %} | ||
# | ||
# Example 1: | ||
# {% include_code javascripts/test.js %} | ||
# | ||
# This will import test.js from source/downloads/code/javascripts/test.js | ||
# and output the contents in a syntax highlighted code block inside a figure, | ||
# with a figcaption listing the file name and download link | ||
# | ||
# Example 2: | ||
# You can also include an optional title for the <figcaption> | ||
# | ||
# {% include_code Example 2 javascripts/test.js %} | ||
# | ||
# will output a figcaption with the title: Example 2 (test.js) | ||
# | ||
|
||
require 'pathname' | ||
require 'coderay' | ||
|
||
module Jekyll | ||
|
||
class IncludeCodeTag < Liquid::Tag | ||
def initialize(tag_name, markup, tokens) | ||
@title = nil | ||
@file = nil | ||
if markup.strip =~ /\s*lang:(\S+)/i | ||
@filetype = $1 | ||
markup = markup.strip.sub(/lang:\S+/i,'') | ||
end | ||
if markup.strip =~ /(.*)?(\s+|^)(\/*\S+)/i | ||
@title = $1 || nil | ||
@file = $3 | ||
end | ||
super | ||
end | ||
|
||
def render(context) | ||
code_dir = context.registers[:site].config['code_dir'].sub(/^\//,'') | ||
code_path = (Pathname.new(context.registers[:site].source) + code_dir).expand_path | ||
file = code_path + @file | ||
|
||
if File.symlink?(code_path) | ||
return "Code directory '#{code_path}' cannot be a symlink" | ||
end | ||
|
||
unless file.file? | ||
return "File #{file} could not be found" | ||
end | ||
|
||
Dir.chdir(code_path) do | ||
code = file.read | ||
@filetype = file.extname.sub('.','') if @filetype.nil? | ||
source = CodeRay.scan(code, @filetype).div(:line_numbers => :inline, :css => :class) | ||
return source | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
Liquid::Template.register_tag('include_code', Jekyll::IncludeCodeTag) |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
include ../../lib/config.mk | ||
|
||
#CC += -faddress-sanitizer -fno-omit-frame-pointer | ||
LDFLAGS := -L"../../lib" -lccv $(LDFLAGS) | ||
CFLAGS := -O3 -Wall -I"../../lib" $(CFLAGS) | ||
|
||
TARGETS = section-001-001 section-001-002 | ||
|
||
all: libccv.a $(TARGETS) | ||
|
||
clean: | ||
${MAKE} clean -C ../../lib ; rm -f *.o $(TARGETS) | ||
|
||
$(TARGETS): %: %.o libccv.a | ||
$(CC) -o $@ $< $(LDFLAGS) | ||
|
||
libccv.a: | ||
${MAKE} -C ../../lib | ||
|
||
%.o: %.c ../lib/ccv.h | ||
$(CC) $< -o $@ -c $(CFLAGS) |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <ccv.h> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
ccv_dense_matrix_t* image = 0; | ||
ccv_read(argv[1], &image, CCV_IO_GRAY | CCV_IO_ANY_FILE); | ||
ccv_write(image, argv[2], 0, CCV_IO_PNG_FILE, 0); | ||
return 0; | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <ccv.h> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
ccv_dense_matrix_t* image = 0; | ||
ccv_read(argv[1], &image, CCV_IO_GRAY | CCV_IO_ANY_FILE); | ||
ccv_bbf_classifier_cascade_t* cascade = ccv_bbf_read_classifier_cascade(argv[2]); | ||
ccv_array_t* faces = ccv_bbf_detect_objects(image, &cascade, 1, ccv_bbf_default_params); | ||
int i; | ||
for (i = 0; i < faces->rnum; i++) | ||
{ | ||
ccv_comp_t* face = (ccv_comp_t*)ccv_array_get(faces, i); | ||
printf("%d %d %d %d\n", face->rect.x, face->rect.y, face->rect.width, face->rect.height); | ||
} | ||
ccv_array_free(faces); | ||
ccv_bbf_classifier_cascade_free(cascade); | ||
ccv_matrix_free(image); | ||
return 0; | ||
} |
This file contains 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 characters
This file contains 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 characters