2012年8月24日 星期五

VMM 2008 R2 PowerShell --- 1 (Domain Admin 權限)

1. 以網域管理者登入VMM主機,開啟PowerShell問題


載入延伸類型資料檔案時發生下列錯誤:
Microsoft.SystemCenter.VirtualMachineManager,C:\Program Files\Microsoft System
Center Virtual Machine Manager 2008 R2\bin\virtualmachinemanager.types.ps1xml :
檔案已因下列驗證例外狀況而被略過: C:\Program Files\Microsoft System Center Virtu
al Machine Manager 2008 R2\bin\virtualmachinemanager.types.ps1xml 檔案無法載入,
因為它的執行已遭軟體限制原則封鎖。如需詳細資訊,請連絡系統管理員。。

2. 問題
     Local administrator 登入,可以載入模組,但無法與VMM連線
     網域管理者可以連線,但無法載入模組
3. 重新建立網用使用者,加入網域管理者群組,工作正常。



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. 結果:




2012年6月28日 星期四

Google Street View Application (kinect) -- 2

Ref:
a. kinect SDK for windows v1.5 Green Screen -WPF
b. Google street view api

1. Green Screen WPF application
2. Add .NET Reference
    System.Drawing
    System.Windows.Forms
3. Add 3 methods (2 event methods) as follows
3-1 SaveWebPage2Image was used to convert google street view as a bitmap
3-2 Mouse_Up was used to replace the background image as a pre-defined street view
3-3 Mouse_Wheel was used to change the heading angle of the previous street view



  public System.Drawing.Bitmap SaveWebPage2Image(string url)
        {
            // Load the webpage into a WebBrowser control
            System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser();
            wb.ScrollBarsEnabled = false;
            wb.ScriptErrorsSuppressed = true;
            wb.Navigate(url);

            while (wb.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete) { System.Windows.Forms.Application.DoEvents(); }

            // Take Screenshot of the web pages full width
            wb.Width = wb.Document.Body.ScrollRectangle.Width;

            // Take Screenshot of the web pages full height
            wb.Height = wb.Document.Body.ScrollRectangle.Height;

            // Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(wb.Width, wb.Height);
            wb.DrawToBitmap(bitmap, new System.Drawing.Rectangle(0, 0, wb.Width, wb.Height));
            wb.Dispose();

            return bitmap;
        }

        int angle1 = 120;
        private void Window_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {

           
            this.Title = "Headingangle : " + angle1.ToString();
            System.Drawing.Bitmap bmp = SaveWebPage2Image(@"http://maps.googleapis.com/maps/api/streetview?size=600x300&location=25.080067,121.397699&heading=" + angle1.ToString() + @"&fov=90&pitch=-10&sensor=false");
            IntPtr hBitmap = bmp.GetHbitmap();
            System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            Backdrop.Source = WpfBitmap;
        }

        private void Window_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            angle1 += 20;
            this.Title = "Headingangle : " + angle1.ToString();
            System.Drawing.Bitmap bmp = SaveWebPage2Image(@"http://maps.googleapis.com/maps/api/streetview?size=600x300&location=25.080067,121.397699&heading=" + angle1.ToString() + @"&fov=90&pitch=-10&sensor=false");
            IntPtr hBitmap = bmp.GetHbitmap();
            System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            Backdrop.Source = WpfBitmap;
        }
4. 下載

2012年6月27日 星期三

Google Street View WPF Application -- 1

將Google 街景圖以WPF之Image控制項展示。
1. 加入WIndowForm元件。 

// Add ref System.Drawing
//         System.Windows.Forms
2. 加入html2bitmap方法

        public System.Drawing.Bitmap SaveWebPage2Image(string url)
        {
            // Load the webpage into a WebBrowser control
            System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser();
            wb.ScrollBarsEnabled = false;
            wb.ScriptErrorsSuppressed = true;
            wb.Navigate(url);

            while (wb.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete) { System.Windows.Forms.Application.DoEvents(); }

            // Take Screenshot of the web pages full width
            wb.Width = wb.Document.Body.ScrollRectangle.Width;

            // Take Screenshot of the web pages full height
            wb.Height = wb.Document.Body.ScrollRectangle.Height;

            // Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(wb.Width, wb.Height);
            wb.DrawToBitmap(bitmap, new System.Drawing.Rectangle(0, 0, wb.Width, wb.Height));
            wb.Dispose();

            return bitmap;
        }
3. 初始設定
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //convert System.Drawing.Image to WPF image
            System.Drawing.Bitmap bmp = SaveWebPage2Image(@"http://maps.googleapis.com/maps/api/streetview?size=600x300&location=25.080067,121.397699&heading=300&fov=90&pitch=-10&sensor=false");
            IntPtr hBitmap = bmp.GetHbitmap();
            System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            im.Source = WpfBitmap;
        }
4. MouseUp Event 改辦視角
        int angle1 = 120;
        private void Window_MouseUp(object sender, MouseButtonEventArgs e)
        {
            angle1 += 20;
            this.Title = "Headingangle : " + angle1.ToString();
            System.Drawing.Bitmap bmp = SaveWebPage2Image(@"http://maps.googleapis.com/maps/api/streetview?size=600x300&location=25.080067,121.397699&heading=" + angle1.ToString() + @"&fov=90&pitch=-10&sensor=false");
            IntPtr hBitmap = bmp.GetHbitmap();
            System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            im.Source = WpfBitmap;
        }
    }
}
5. 下載