Using ls command

ls -w1 */  - show only subdirectories in current directory (*/) and display in 1 column (-w1)
ls -c  - sort by date

Некоторые заметки о приведении типов в СиПлюсПлюс

АлёнаC++:
http://alenacpp.blogspot.ru/2005/08/c.html

static_cast между указателями корректно, только если один из указателей - это указатель на void или если это приведение между объектами классов, где один класс является наследником другого. То есть для приведения к какому-либо типу от void*, который возвращает malloc, следует использовать static_cast.
int * p = static_cast<int*>(malloc(100));
Если приведение не удалось, возникнет ошибка на этапе компиляции. Однако, если это приведение между указателями на объекты классов вниз по иерархии и оно не удалось, результат операции undefined. То есть, возможно такое приведение: static_cast<Derived*>(pBase), даже если pBase не указывает наDerived, но программа при этом будет вести себя странно.

Math morphology in Adobe After Effects

Errosion and dilation in AE is implemented in Minimax filter. See settings bellow:

Opencv and "OpenCV Error: Bad flag"


   
I had pretty simple code with opencv:

    cv::Mat t;
    t = cv::imread( "qq.bmp" ) ;
    cv::imwrite( "q.bmp", t );
    cv::namedWindow( "asdads", CV_WINDOW_AUTOSIZE );
    cv::imshow( "asdads", t );
    cv::waitKey( -1 );
    return 0;

It caused crash in debug configuration:

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupport
ed array type) in unknown function, file ..\..\..\src\opencv\modules\core\src\ar
ray.cpp, line 2482

In release configuration it was ok. Finally i found the solution. Both in debug and release configurations I used static libraries for release conguration

opencv_core231.lib opencv_imgproc231.lib opencv_highgui231.lib

And one should use
opencv_core231d.lib opencv_imgproc231d.lib opencv_highgui231d.lib
for debug.

It seems wrong libraries cause crashes only sometimes. I had used release version of static opencv libraries for my debu and release configurations for a long time an only now it caused problems


OpenCV. Copy image from unsigned char buffer, resize and save to file

How to copy image from unsigned char buffer, resize and save to file.
If you use single-channel image.

#include <opencv/cv.h>
#include <opencv/highgui.h>

                int coeff = 4;
                cv::Mat src( height, width, CV_8UC1, (void *) source_byte_beffer ) );
                cv::Mat small(height/ coeff, width/ coeff, CV_8UC1 );

                cv::Size s_half(width/ coeff, height/ coeff);
                cv::resize( src, small, s_half, 1, 1, cv::INTER_LINEAR ); // resize from src to small

                IplImage* writeImage;
                writeImage=cvCloneImage(&(IplImage)src);
                cvSaveImage("src1.bmp", writeImage);
                cvReleaseImage( &writeImage );

                writeImage=cvCloneImage(&(IplImage)small);
                cvSaveImage("little.bmp", writeImage);
                cvReleaseImage( &writeImage );


                //Another way of writtting:               
                /*cvWrite("src.bmp", src );
                cv::imwrite( "small.bmp", small );*/

                
         

SVN copy certain subdirectories to a branch

There was always a problem for me to copy only certain directories from one branch to another.
For example we have following directory structure:
trunk
      - project1
      - project2
          -subdir1
          -subdir2
          -subdir3        
We want to copy only subdir2 to a branch /branches/branch1 with saving all the structure of projects.
branches/branch1
      - project1
      - project2
          -subdir2
We want to copy only subdir2 to a branch /branches/branch1 with saving all the structure of projects.
Such a manipulation is required if you want to make a private branch for outsorcer and you don't wan him to see the other parts of the code. However you want to support reintegration of the branch back to the trunk.

The solution is 
svn cp --parents ./project2/subdir2 http://repo.url/branches/branch1/project2/subdir2
or
svn cp --parents http://<svn_path>/trunk/project2/subdir2 <working copy path>/branches/branch1/project2/subdir2
Subversion creates all intermediate directories.

Trim frames from raw YUV video using FFMPEG

Trim 5 frames starting from 160-th frame and write to png sequence

ffmpeg -pix_fmt yuv420p -s 1920x1088  -r 1 -i input_video.yuv -r 1 -ss 160 -frames 5  output_sequence_%d.png

size of input video is 1920x1088, format YUV420 progressive

UPD:
ffmpeg is renamed to avconv.
Using it for trimming AVI video:

avconv -ss 00:58:00 -t 00:59:30 -i ./video.avi frame_%05d.png