Ejemplo n.º 1
0
        // class constructor 
        public Camera() 
        { 
            // set up image formats 
            NaoCamImageFormat format120 = new NaoCamImageFormat(); 
            NaoCamImageFormat format240 = new NaoCamImageFormat(); 
            NaoCamImageFormat format480 = new NaoCamImageFormat(); 
            NaoCamImageFormat format960 = new NaoCamImageFormat(); 
 
            format120.name = "160 * 120"; 
            format120.id = 0; 
            format120.width = 160; 
            format120.height = 120; 
 
            format240.name = "320 * 240"; 
            format240.id = 1; 
            format240.width = 320; 
            format240.height = 240; 
 
            format480.name = "640 * 480"; 
            format480.id = 2; 
            format480.width = 640; 
            format480.height = 480; 
 
            format960.name = "1280 * 960"; 
            format960.id = 3; 
            format960.width = 1280; 
            format960.height = 960; 
 
            // add them to the formats list 
            NaoCamImageFormats.Add(format120); 
            NaoCamImageFormats.Add(format240); 
            NaoCamImageFormats.Add(format480); 
            NaoCamImageFormats.Add(format960); 
        } 
Ejemplo n.º 2
0
        /// <summary> 
        /// Connects to the camera on the NAO robot 
        /// </summary> 
        /// <param name="ip"> the ip address of the robot </param> 
        /// <param name="format"> the video format desired </param> 
        /// <param name="ColorSpace"> the video color space </param> 
        /// <param name="FPS"> the FPS of the video </param> 
        public void connect(string ip, NaoCamImageFormat format, int ColorSpace, int FPS) 
        { 
            try 
            { 
                if (naoCamera != null) 
                { 
                    Disconnect(); 
                } 
 
                naoCamera = new VideoDeviceProxy(ip, 9559); 
 
                // Attempt to unsubscribe incase program was not shut down properly 
                try 
                { 
                    naoCamera.unsubscribe("NAO Camera"); 
                } 
                catch (Exception) 
                { 
                } 
 
                // subscribe to NAO Camera for easier access to camera memory 
                naoCamera.subscribe("NAO Camera", format.id, ColorSpace, FPS); 
            } 
            catch (Exception e) 
            { 
                // display error message and write exceptions to a file 
                MessageBox.Show("Exception occurred, error log in C:\\NAOcam\\exception.txt"); 
                naoCamera = null; 
                System.IO.File.WriteAllText(@"C:\\NAOcam\\exception.txt",e.ToString()); 
            } 
        } 
Ejemplo n.º 3
0
        /// <summary>
        /// Connects to the camera on the NAO robot
        /// </summary>
        /// <param name="ip"> the ip address of the robot </param>
        /// <param name="format"> the video format desired </param>
        /// <param name="ColorSpace"> the video color space </param>
        /// <param name="FPS"> the FPS of the video </param>
        public void connect(string ip, NaoCamImageFormat format, int ColorSpace, int FPS)
        {
            try
            {
                if (naoCamera != null)
                {
                    Disconnect();
                }

                naoCamera = new VideoDeviceProxy(ip, 9559);

                // Attempt to unsubscribe incase program was not shut down properly
                try
                {
                    naoCamera.unsubscribe("NAO Camera");
                }
                catch (Exception)
                {
                }

                // subscribe to NAO Camera for easier access to camera memory
                naoCamera.subscribe("NAO Camera", format.id, ColorSpace, FPS);
            }
            catch (Exception e)
            {
                // display error message and write exceptions to a file
                MessageBox.Show("Exception occurred, error log in C:\\NAOserver\\exception.txt");
                naoCamera = null;
                System.IO.File.WriteAllText(@"C:\\NAOserver\\exception.txt", e.ToString());
            }
        }
Ejemplo n.º 4
0
        // class constructor
        public Camera()
        {
            // set up image formats
            NaoCamImageFormat format120 = new NaoCamImageFormat();
            NaoCamImageFormat format240 = new NaoCamImageFormat();
            NaoCamImageFormat format480 = new NaoCamImageFormat();
            NaoCamImageFormat format960 = new NaoCamImageFormat();

            format120.name   = "160 * 120";
            format120.id     = 0;
            format120.width  = 160;
            format120.height = 120;

            format240.name   = "320 * 240";
            format240.id     = 1;
            format240.width  = 320;
            format240.height = 240;

            format480.name   = "640 * 480";
            format480.id     = 2;
            format480.width  = 640;
            format480.height = 480;

            format960.name   = "1280 * 960";
            format960.id     = 3;
            format960.width  = 1280;
            format960.height = 960;

            // add them to the formats list
            NaoCamImageFormats.Add(format120);
            NaoCamImageFormats.Add(format240);
            NaoCamImageFormats.Add(format480);
            NaoCamImageFormats.Add(format960);
        }
Ejemplo n.º 5
0
        /// <summary> 
        /// Class constructor 
        /// </summary> 
        /// <param name="ip"> ip address of the robot </param> 
        /// <param name="format"> image format to use </param> 
        /// <param name="colorSpace"> color space to use </param> 
        /// <param name="FPS"> FPS to use </param> 
        /// <param name="currentCamera"> instance of the camera class to use 
        /// <param name="currentStorage"> instance of the DataStorage class to use 
        public GetFrame(string ip, NaoCamImageFormat format, int colorSpace, int 
FPS, Camera currentCamera, DataStorage currentStorage) 
        { 
            naoCam = currentCamera; 
            storage = currentStorage; 
 
            naoCam.connect(ip, format, colorSpace, FPS); 
        } 
Ejemplo n.º 6
0
        /// <summary> 
        /// Class constructor, starts getting frames from the robot 
        /// and makes a connection to the motion and audio classes 
        /// </summary> 
        /// <param name="ip"> ip address of the NAO robot </param> 
        public _640window(string ip) 
        { 
            InitializeComponent(); 
 
            // puts the IP in the ipBox so the user knows which NAO the program is connected to 
            ipBox.Text = ip; 
 
            // call the Camera constuctor, and set the image format to 640x480 
            naoCam = new Camera(); 
            currentFormat = naoCam.NaoCamImageFormats[2]; 
            HDFormat = naoCam.NaoCamImageFormats[3]; 
 
            // call the Motion constructor 
            naoMotion = new Motion();  
 
            // call the Audio constructor 
            naoAudio = new Audio(); 
 
            // create timer to display recording time 
            recordingTimer.Interval = new TimeSpan(0,0,1); 
            recordingTimer.Tick += new EventHandler(recordingTimeIncrease); 
 
            try // attempt to connect to the camera and motion system 
            { 
                // connect to the NAO Motion API 
                naoMotion.connect(ipBox.Text); 
 
                // create the newFrames instance of the getFrames class 
                newFrames = new GetFrame(ipBox.Text, currentFormat, COLOR_SPACE, FPS, naoCam, storage); 
 
                // create a new thread to allow frame acquisition to occur without interrupting UI smoothness 
                frameThread = new Thread(new ThreadStart(newFrames.grabFrame)); 
 
                // start the thread 
                frameThread.Start(); 
 
                // Create a timer for event based frame acquisition.  
                // Program will get new frame from storage based on FPS 
                dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 
(int)Math.Ceiling(1000.0 / 30)); 
                dispatcherTimer.Start(); 
 
                // whenever the timer ticks the bitmapReady event is called 
                dispatcherTimer.Tick += new EventHandler(bitmapReady); 
 
                // let rest of program know that camera is ready 
                isCamInitialized = true; 
            } 
            catch (Exception ex) 
            { 
                isCamInitialized = false; 
 
                // display error message and write exceptions to a file 
                MessageBox.Show("Exception occurred, error log in C:\\NAOcam\\exception.txt"); 
                System.IO.File.WriteAllText(@"C:\\NAOcam\\exception.txt", ex.ToString()); 
            } 
        } 
Ejemplo n.º 7
0
        /// <summary> 
        /// constuctor for MainWindow 
        /// </summary> 
        public MainWindow() 
        { 
            InitializeComponent(); 
 
            // call the Camera constuctor, and set the image format to 640x480 
            naoCam = new Camera(); 
 
            // call the Motion constructor 
            naoMotion = new Motion(); 
 
            currentFormat = naoCam.NaoCamImageFormats[2]; 
 
            // Make sure the standard output directory exists 
            if (!System.IO.Directory.Exists("C:\\NAOserver\\")) 
            { 
                System.IO.Directory.CreateDirectory("C:\\NAOserver\\"); 
            } 
        } 
Ejemplo n.º 8
0
        /// <summary> 
        /// constuctor for MainWindow 
        /// </summary> 
        public MainWindow() 
        { 
            InitializeComponent(); 
 
            // call the Camera constuctor, and set the image format to 320x240  
            naoCam = new Camera(); 
 
            // call the Motion constructor 
            naoMotion = new Motion();

            // call the Audio constructor 
            naoAudio = new Audio(); 
 
            currentFormat = naoCam.NaoCamImageFormats[1]; //angka 1 menunjukkan res 320x240
 
            // Make sure the standard output directory exists 
            if (!System.IO.Directory.Exists("C:\\NAOserver\\")) 
            { 
                System.IO.Directory.CreateDirectory("C:\\NAOserver\\"); 
            } 
        }