2012年7月26日 星期四

Bootable USB

Ref:http://www.intowindows.com/bootable-usb/

1. Hardware: Transcend 8G USB
2. Target Windows 7 x64
3. CMD by role of administrator
4. diskpart/list disk/ Select Disk #/clean
5.create partition primary/select partition 1/active/format fs=ntfs
6. assign
7. exit
8. g: (Windows 7 @ Driver G:)
9. cd boot
10. Bootsect.exe /NT60 I:     (USB @ Driver I:)
11. cd\
12. xcopy *.* I: /s   (Change to root and copy all files into USB driver)




2012年7月3日 星期二

emgu WPF facedetection

To combine WPF,cameraCapture and faceDetection
1. WPF example (Key function)
public static BitmapSource ToBitmapSource(IImage image)
2. CameraCapture acquires images in windowform control, it may be converted into WPF image by the previous method.
3. Get the image and detect face and eyes, passing it into WPF image.
    Notes: Add System.Drawing for some of items such as Size ==> System.Drawing.Size,
               Color -> System.Drawing.Color ... etc.

    public Window1()
        {
            InitializeComponent();
            this.Dispatcher.Hooks.DispatcherInactive += new EventHandler(ProcessFrame);
            _capture = new Capture();
        }

        private Capture _capture;
        private bool _captureInProgress;
        private void ProcessFrame(object sender, EventArgs arg)
        {
            Image<Bgr, Byte> frame = _capture.QueryFrame();
            Image<Gray, Byte> gray = frame.Convert<Gray, Byte>(); //Convert it to Grayscale

            //Stopwatch watch = Stopwatch.StartNew();
            this.Dispatcher.Hooks.DispatcherInactive -= new EventHandler(ProcessFrame);
            //normalizes brightness and increases contrast of the image
            gray._EqualizeHist();

            //Read the HaarCascade objects

            HaarCascade face = new HaarCascade("haarcascade_frontalface_alt_tree.xml");
            HaarCascade eye = new HaarCascade("haarcascade_eye.xml");

            //Detect the faces  from the gray scale image and store the locations as rectangle
            //The first dimensional is the channel
            //The second dimension is the index of the rectangle in the specific channel
            MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(
               face,
               1.1,
               10,
               Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
               new System.Drawing.Size(20, 20));

            foreach (MCvAvgComp f in facesDetected[0])
            {
                //draw the face detected in the 0th (gray) channel with blue color
                //image.Draw(f.rect, new Bgr(Color.Blue), 2);
                frame.Draw(f.rect, new Bgr(System.Drawing.Color.Blue), 2);

                //Set the region of interest on the faces
                gray.ROI = f.rect;
                MCvAvgComp[][] eyesDetected = gray.DetectHaarCascade(
                   eye,
                   1.1,
                   10,
                   Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                   new System.Drawing.Size(20, 20));
                gray.ROI = System.Drawing.Rectangle.Empty;

                foreach (MCvAvgComp e in eyesDetected[0])
                {
                    System.Drawing.Rectangle eyeRect = e.rect;
                    eyeRect.Offset(f.rect.X, f.rect.Y);
                    frame.Draw(eyeRect, new Bgr(System.Drawing.Color.Red), 2);
                }
            }

            image1.Source = ToBitmapSource(frame);
            this.Dispatcher.Hooks.DispatcherInactive += new EventHandler(ProcessFrame);
        }
4. 下載

2012年7月2日 星期一

Emgu x64 FaceDetection

Ref: http://lucas-0706.blogspot.tw/2012/02/emgu-cv-on-visual-c-2010.html
電腦 ASUS A43S, OS: Windows 7 x64

1. 加入參考路徑 C:\Users\csjou\Downloads\emgux64\libemgucv-windows-x64-2.2.1.1150\libemgucv-windows-x64-2.2.1.1150\bin\
2. 重新加入 Emgu.DLL, Emgu.CV.DLL, Emgu.Util
3. 重新加入既有項目
    CommonAssemblyInfo.cs
    haarcascade_eye.xml
    haarcascade_frontalface_alt_tree.xml
4. 變更檔案屬性為永遠複製
      haarcascade_eye.xml
      haarcascade_frontalface_alt_tree.xml
5. 變更輸出bin位置
6. 變更我的電腦 環境變數 Path 加入 C:\Users\csjou\Downloads\emgux64\libemgucv-windows-x64-2.2.1.1150\libemgucv-windows-x64-2.2.1.1150\bin\
7. 結果: