Maltab Layout File Location

You might love your matlab layout configuration and may want to keep and use it along with you.

Here is the location of the layout file,

Windows:
C:\Documents and Settings\username\Application Data\MathWorks\MATLAB\R2009a

Mac:
/Users/username/.matlab/R2009a/

Comments(0)

Communicating between processes with Pipe

Instead of using a complicated Sendmessge between processes, there is another convenient way to communicate between processes. Pipe!

There is a good tutorial and implementation demo with C#. link

I just used the server client in my program. But for the client, I used a simple C++ implementation.

HANDLE h=NULL;
void send_message(char *msg)
{
	if (!h)
		{
			h=CreateFile(L"\\\\.\\pipe\\MyNamedPip",
			      GENERIC_READ | GENERIC_WRITE,
                  0,
                  NULL,
                  OPEN_EXISTING,
                  FILE_FLAG_OVERLAPPED,
				  NULL);
		}

	DWORD BytesWritten;
	WriteFile(h,msg,strlen(msg),&BytesWritten,NULL);
	FlushFileBuffers(h);
}

Tags: , ,

Comments(0)

Declare an array of object references in VC++.net

上了贼船, 只能当贼.
Following the weird syntax of VC++.net, here is how to declare an array of a dotnet object references.

static array<System::Threading::Mutex^>^ trackers_mut = gcnew array<System::Threading::Mutex^>(10);

or

array <String^>^ filenames={"aa", "bb"};

有点抓狂. 但的确是这么写的. C及其衍生物总是那么变化无穷.

Tags:

Comments(0)

Using Windows Media Player Control in Visual Studio

In Old times, I still remember how cool it is to add a media player in my Delphi Form. Now I need to do the same to VC++.net, so I searched and got these links. Although they are not VC++.net solution, they still help a lot.

With some codec (here), this way can enable your application play video of most popular formats. So give up the other version of using Direct X to play only AVI format video in dotnet application.

Here are the links (still updating)

How to add Windows Media Player Control to Design ToolBox

How to use Windows Media Player in code (C# Version)

Tags: , ,

Comments(0)

How to configue OpenCV in Visual Studio – Reprice

It has been quite a while since last time I post a howto of configuring OpenCV in Visual Studio. The post got a lot of attention and comments. As the the configuring has become simpler, the post becomes a bit bulky and out-of-date. So right now I am considering to rewrite the howto with a much simpler version.

  • Open Visual Studio, add following path to
    Tools–>Options–>Projects–>VC++ Directories–>Include files

    C:\Program Files\OpenCV\cv\include
    C:\Program Files\OpenCV\otherlibs\highgui
    C:\Program Files\OpenCV\cxcore\include
    C:\Program Files\OpenCV\otherlibs\cvcam\include
  • Add following path to Tools–>Options–>Projects–>VC++ Directories–>Library files
    C:\Program Files\OpenCV\lib
  • When create a new project,
    add following to “Project–>Properties–>Linker->Input–>Additonal dependencies

    cv.lib highgui.lib cvaux.lib cxcore.lib

    NOTE there is no difference between debug or release configurations

  • Tested on OpenCV 1.0 with Visual Studio 2008

    Links
    Original blogspot link1 link2.
    Li Hao’s post.

    Tags: ,

    * Comments(2)

    Using OpenCV in VC++.Net

    Continuous updating…
    Current testing version: OpenCV 1.0 (I do not recommend the latest 1.1pre1. I got strange error using it in VC.net). VC++.net 2008.

    Set up a project in Visual Studio

  • Choose VC++ -> Windows Forms Application (stand for dotnet framework)
  • Add opencv directory and dependent library from this post.
  • Add include <cv.h> to try out.
  • Compile, you might find an error saying ” cannot compile under /clr:safe or /clr:pure …”
  • Then goto Project setting: Configuration properties -> general -> Common Language Runtime Support -> change to  (/clr)
  • Compile again, it should work.
  • Convert IplImage to VC++.net Bitmap

    System::Drawing::Bitmap ^disp = gcnew System::Drawing::Bitmap(img->width, img->height, img->widthStep, PixelFormat::Format24bppRgb, System::IntPtr::IntPtr( img->imageData) );

    Tags: ,

    Comments(0)

    using algorthim package in latex

    贴点sample上来, 便于日后参考.
    用这个package可以产生把algorithm的caption放在最上面, 并且排版会漂亮一点.

    \usepackage{algorithmic}
    \usepackage[ruled]{algorithm2e}
    

    下面是一段sample code, 需要的时候自己根据需要改成自己要的.

    \begin{algorithm}[H]
    \KwIn{Photo} \KwOut{Detected Person $p$} \SetLine { Detect all
    upper bodies\; Detect all faces \;} \ForEach{upper body detected
    $u$}{ Find the largest faces $f$ which has at least $50\%$ overlap
    with $u$\;
    \If {such $f$ exists}
    {
    Construct $p$ from $f$ and $u$: \\
    \{   \\   The upper part of the detect result $p$ is set to $f$\;
    The lower part of $p$ is set to the lower part of $u$ right below $f$\;
    \} \\
    Put $p$ into the result list\;
    }
    }
    \caption{Human subject detection (combining upper body
    detection and face detection)} \label{alg:detect}
    \end{algorithm}
    

    Thank ajay for help

    Tags:

    Comments(0)

    Mac上装Matlab r2009a

    此版本的matlab会直接在application目录下装一个app文件,相比原来的安装更符合mac os的设计.
    整个安装过程非常简便和快速, 甚至比windows版的还快.
    但激活matlab可能有个问题, 会发现activate matlab这个app会crash.
    原因是这个激活的app是32bit的,但java默认按照64bit来跑.
    解决方法是, 在打开/Applications/Utilities/Java/Java Preferences, 修改默认的java程序运行环境为32bit,等激活后,再改回64bit.

    此外, 之前看到了一个matlab加速的方法,是
    自己加一个java.opts文件,放在/$Matlab$/bin/maci/目录下,
    文件内容是
    -Dapple.awt.graphics.UseQuartz=true
    让matlab的java程序默认使用tiger的Quartz来render 界面.

    但在r2009a里,这个文件自己就在那儿了, 不用自己添加了. matlab界面的速度也非常理想了.

    refer

    http://www.mathworks.com/support/solutions/data/1-8GS5S1.html?product=ML&solution=1-8GS5S1

    Tags: ,

    * Comments(2)