2016年4月20日星期三

编译obs和 niginx_rtmp_module

nignx https支持


brew link openssl --force

--with-ld-opt="-L /usr/local/lib"


编译 obs 需要的patch

JIANFU-M-63ED:bld jeromy$ git diff
diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt
index 3cf6bd8..fcfaa79 100644
--- a/libobs/CMakeLists.txt
+++ b/libobs/CMakeLists.txt
@@ -72,6 +72,8 @@ if(WIN32)
                w32-pthreads)
        endif()
 elseif(APPLE)
+        link_directories(/usr/local/lib)
+
        set(libobs_PLATFORM_SOURCES
                obs-cocoa.c
                util/threading-posix.c
@@ -102,11 +104,26 @@ elseif(APPLE)
        mark_as_advanced(CARBON)
        include_directories(${CARBON})

+        find_library(SECURITY Security)
+        find_library(COREVIDEO CoreVideo)
+        find_library(COREAUDIO CoreAudio)
+       find_library(COREMEDIA CoreMedia)
+        find_library(AUDIOTOOLBOX AudioToolbox)
+        find_library(VIDEOTOOLBOX VideoToolbox)
+        find_library(VDA VideoDecodeAcceleration)
+
        set(libobs_PLATFORM_DEPS
                ${COCOA}
                ${APPKIT}
                ${IOKIT}
-               ${CARBON})
+               ${CARBON}
+                ${SECURITY}
+                ${COREVIDEO}
+                ${COREAUDIO}
+                ${AUDIOTOOLBOX}
+                ${VIDEOTOOLBOX}
+                ${VDA}
+                ${COREMEDIA})
 elseif(UNIX)
        set(libobs_PLATFORM_SOURCES
                obs-nix.c
@@ -371,6 +388,20 @@ target_link_libraries(libobs
                ${OBS_JANSSON_IMPORT}
                ${FFMPEG_LIBRARIES}
                ${ZLIB_LIBRARIES}
+                fdk-aac
+                iconv
+                x264
+                xvidcore
+                vpx
+                vorbis
+                vorbisenc
+                theora
+                theoraenc
+                opus
+                tiff
+                mp3lame
+                lzma
+                bz2
        PUBLIC
                ${THREADS_LIBRARIES})

diff --git a/obs/CMakeLists.txt b/obs/CMakeLists.txt
index c98b9bc..965c488 100644
--- a/obs/CMakeLists.txt
+++ b/obs/CMakeLists.txt
@@ -72,6 +72,8 @@ elseif(APPLE)
                add_definitions(-DUPDATE_SPARKLE=1)
        endif()

+        link_directories(/usr/local/lib)
+
 elseif(UNIX)
         find_package(Qt5X11Extras REQUIRED)

@@ -219,6 +221,14 @@ target_link_libraries(obs
        libobs
        libff
        Qt5::Widgets
+        freetype
+        sdl
+        ass
+        postproc
+        "-framework AVFoundation"
+        "-framework CoreMedia"
+        "-framework CoreVideo"
+        "-framework QTKit"
        ${LIBCURL_LIBRARIES}
        ${obs_PLATFORM_LIBRARIES})

diff --git a/plugins/obs-ffmpeg/CMakeLists.txt b/plugins/obs-ffmpeg/CMakeLists.txt
index 511431d..26e888e 100644
--- a/plugins/obs-ffmpeg/CMakeLists.txt
+++ b/plugins/obs-ffmpeg/CMakeLists.txt
@@ -8,6 +8,7 @@ endif()
 find_package(FFmpeg REQUIRED
        COMPONENTS avcodec avfilter avdevice avutil swscale avformat swresample)
 include_directories(${FFMPEG_INCLUDE_DIRS})
+link_directories(/usr/local/lib)

 set(obs-ffmpeg_HEADERS
        obs-ffmpeg-formats.h
@@ -26,6 +27,17 @@ add_library(obs-ffmpeg MODULE
 target_link_libraries(obs-ffmpeg
        libobs
        libff
+        freetype
+        sdl
+        ass
+        postproc
+        "-framework Foundation"
+        "-framework QTKit"
+        "-framework AVFoundation"
+        "-framework CoreMedia"
+        "-framework CoreVideo"
+        "-framework CoreGraphics"
+        "-framework CoreFoundation"
        ${obs-ffmpeg_PLATFORM_DEPS}
        ${FFMPEG_LIBRARIES})

diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/CMakeLists.txt b/plugins/obs-ffmpeg/ffmpeg-mux/CMakeLists.txt
index 8c564d8..7abb84e 100644
--- a/plugins/obs-ffmpeg/ffmpeg-mux/CMakeLists.txt
+++ b/plugins/obs-ffmpeg/ffmpeg-mux/CMakeLists.txt
@@ -3,6 +3,7 @@ project(ffmpeg-mux)
 find_package(FFmpeg REQUIRED
        COMPONENTS avcodec avutil avformat)
 include_directories(${FFMPEG_INCLUDE_DIRS})
+link_directories(/usr/local/lib)

 set(ffmpeg-mux_SOURCES
        ffmpeg-mux.c)
@@ -14,7 +15,34 @@ add_executable(ffmpeg-mux
        ${ffmpeg-mux_SOURCES}
        ${ffmpeg-mux_HEADERS})

+
 target_link_libraries(ffmpeg-mux
+        fdk-aac
+        iconv
+        x264
+        xvidcore
+        vpx
+        vorbis
+        vorbisenc
+        theora
+        theoraenc
+        opus
+        tiff
+        mp3lame
+        lzma
+        swresample
+        bz2
+        z
+        "-framework Foundation"
+        "-framework Security"
+        "-framework AudioToolbox"
+        "-framework VideoToolbox"
+        "-framework VideoDecodeAcceleration"
+        "-framework AVFoundation"
+        "-framework CoreMedia"
+        "-framework CoreVideo"
+        "-framework CoreGraphics"
+        "-framework CoreFoundation"
        ${FFMPEG_LIBRARIES})

 if(WIN32)





opencv patch

JIANFU-M-63ED:opencv jeromy$ git diff
diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt
index 41b0691..b958457 100644
--- a/modules/videoio/CMakeLists.txt
+++ b/modules/videoio/CMakeLists.txt
@@ -147,7 +147,7 @@ if(HAVE_FFMPEG)
     list(APPEND VIDEOIO_LIBRARIES ${BZIP2_LIBRARIES})
   endif()
   if(APPLE)
-    list(APPEND VIDEOIO_LIBRARIES "-framework VideoDecodeAcceleration" bz2)
+    list(APPEND VIDEOIO_LIBRARIES "-framework Security" "-framework CoreMedia" "-framework CoreVideo" "-framework AudioToolbox" "-framework VideoToolbox" "-framework VideoDecodeAcceleration" bz2)
   endif()
 endif(HAVE_FFMPEG)

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