2016年3月24日星期四

compile opencv 3 with ffmpeg in OS X

Some framework not set correctly.

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON2_PACKAGES_PATH=~/Library/Python/2.7/lib/python/site-packages/ \
-D PYTHON2_LIBRARY=~/Library/Python/2.7/bin/ \
-D PYTHON2_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Headers \
-D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \

-D OPENCV_EXTRA_MODULES_PATH=/Users/jeromy/work/personal/opencv_contrib/modules ..


change /Users/jeromy/work/personal/opencv/modules/videoio/CMakeLists.txt line 150 to:

     list(APPEND VIDEOIO_LIBRARIES "-framework Security" "-framework CoreMedia" "-framework CoreVideo" "-framework AudioToolbox" "-framework VideoToolbox" "-fra    mework VideoDecodeAcceleration" bz2)

2015年4月30日星期四

正则表达式Lookahead

Say I want to retrieve from a text document all the words that are immediately followed by a comma. We’ll use this example string:
What then, said I, shall I do?  You shan't, he replied, do anything.
As a first attempt, I could use this regular expression to get one or more word parts followed by a comma:
[A-Za-z']+,
This yields four results over the string:
  1. then,
  2. I,
  3. shan't,
  4. replied,
Notice that this gets me the comma too, though, which I would then have to remove.  Wouldn’t it be better if we could express that we want to match a word that is followed by a comma without also matching the comma?
We can do that by modifying our regex as follows:
[A-Za-z']+(?=,)
This matches groups of word characters that are followed by a comma, but because of the use of lookahead the comma is not part of the matched text (just as we want it not to be).  The modified regex results in these matches:
  1. then
  2. I
  3. shan't
  4. replied

A Positive Negative Example

What if I wanted to match all the words not followed by a comma?  I would use negative lookahead:
(?>[A-Za-z']+)(?!,)
(Okay, negative lookahead and atomic grouping)
…to get these matches:
  1. What
  2. said
  3. shall
  4. I
  5. do
  6. You
  7. he
  8. do
  9. anything

Huh? Atomic Grouping?

Yep.  Otherwise you’ll get the following (unintended matches highlighted):
  1. What
  2. the
  3. said
  4. shall
  5. I
  6. do
  7. You
  8. shan’
  9. he
  10. replie
  11. do
  12. anything
Without atomic grouping (the (?>) in the regex), when the regex engine sees that a match-in-progress comes up against a disqualifying comma, it simply backs off one letter to complete the match: the + in the regex gives the engine that flexibility.  Applying atomic grouping disallows this and says, don’t give up characters you’ve matched.

When Lookahead Does You No Good

Lookahead doesn’t really help if you only care whether or not there was a match (that is, you don’t care what text was matched).  If  all I care about is whether or not the string contains any words followed by a comma, I would dump lookahead and use the simpler regex:
[A-Za-z']+,

Acknowledgments

Thanks to Jeffrey Friedl for writing Mastering Regular Expressions, 3rd ed., before reading which I had not even heard of regex lookahead.
Also, thanks to Sergey Evdokimov for his online Regular Expression Editor.  Handy!
online-regex-editor
  1. #1 by Aaron Alexander on March 25, 2009 - 2:26 pm
    I thought I’d point out another online regular expression editor that I use: Rubular.
    Thanks for the article, by the way. I didn’t know about the lookahead feature.
  2. #2 by Witek on June 11, 2013 - 11:39 am
    It would be from performance and regular expression semantic, much better to use matching and negative character class.
    ([A-Za-z’]+),
    ([A-Za-z’]+)([^,]|$) # followed by non-coma, or end of string.
    and use group 1.
  3. #3 by sars on September 4, 2013 - 6:30 am
    I need more explanation on atomic grouping,,,
    Thanks in advance
  4. #4 by Max on September 26, 2013 - 10:47 am
    I want a regex that will validate number between 1 to 9 except 7. i.e, it will initially check if a given number is in the range of 1 to 9 , if true then another check will make if that given number is 7 or not. If its 7 then fail else pass. Does anyone have any idea. Your help will be highly appreciated .
  5. #5 by danielmeyer on September 26, 2013 - 10:59 am
    Dear Max,
    Why don’t you write out your best guess, and then we’ll work on it from there.
    Daniel
  1. Ascertaining how subtract works with Strings in Groovy « All things Grails and RIA
  2. Groovy Regex text manipulation example « All things Grails and RIA
  3. Groovy Regular Expressions to abbreviate compass directions with look ahead and look behind. « All things Grails and RIA

2014年12月6日星期六

ruby

http://www.railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
http://thoughts.codegram.com/understanding-class-instance-variables-in-ruby/
http://www.devalot.com/articles/2008/09/ruby-singleton
http://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/45-more-classes/lessons/110-instance-variables

https://ruby-china.org/wiki/coding-style
http://www.alanmacdougall.com/blog/2012/06/08/interactive-debugging-with-pry/

Mobile TA

http://www.vogella.com/tutorials/Robotium/article.html

https://code.google.com/p/robotium/

2014年12月2日星期二

Histogram

http://toyoizumilab.brain.riken.jp/hideaki/res/histogram.html

http://pubs.research.avayalabs.com/pdfs/ALR-2007-003-paper.pdf

http://stats.stackexchange.com/questions/6753/when-to-use-equal-frequency-histograms

2014年11月21日星期五

Running median

http://stats.stackexchange.com/questions/7959/algorithm-to-dynamically-monitor-quantiles
http://stats.stackexchange.com/questions/103258/online-estimation-of-quartiles-without-storing-observations

http://en.wikipedia.org/wiki/Reservoir_sampling

https://dcc.ligo.org/T030168/public

http://web.ipac.caltech.edu/staff/fmasci/home/statistics_refs/Remedian.pdf

http://stats.stackexchange.com/questions/346/what-is-a-good-algorithm-for-estimating-the-median-of-a-huge-read-once-data-set

http://stackoverflow.com/questions/1309263/rolling-median-algorithm-in-c

http://stackoverflow.com/questions/10930732/c-efficiently-calculating-a-running-median

2014年11月13日星期四

of the Best Free and Open Source Data Mining

5 of the Best Free and Open Source Data Mining Software | TechSource


Posts in Gerald Lushington’s open source software blog represent the honest opinions of an open source software fan who has not been influenced by commercial interests or other inducements.