Problem with getting frames in C#

leith
Posts: 194
Joined: Tue Jan 02, 2007 2:17 pm

Re: Problem with getting frames in C#

Post by leith »

hrm... I downloaded the .net 3.0 sample and its actually acting really strange. It also is not drawing frames except in tiny little spurts once every 10 to 20 seconds even though I have plenty of markers fully in view.

I'm beginning to wonder if this is a windows vista or dotNet issue?

I've quickly written a simpler loop

Code: Select all

/*
 * Created by SharpDevelop.
 * User: leith
 * Date: 11/16/2007
 * Time: 3:04 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using OptiTrack;


namespace FIEMC2DNodeCL
{
    class Program
    {
        public static void InitCamera(NPCamera cam){
            cam.SetLED(0, true);
            cam.SetLED(1, true);
            cam.SetLED(2, false);
            cam.Open();
            cam.Start();
        }
        
        public static void Main(string[] args)
        {
            OptiTrack.NPCameraCollectionClass cameras = new NPCameraCollectionClass();
            cameras.Enum();
            cameras.Synchronize();
            foreach (NPCamera cam in cameras){
                InitCamera(cam);
            }
            bool closeRequested = false;
            while (!closeRequested){
                int frames = 0;
                int points = 0;
                foreach (NPCamera cam in cameras){
                    OptiTrack.NPCameraFrame frame = null;
                    frame = cam.GetFrame(0);
                    while (frame != null){                        
                        if (frame.IsEmpty){
                            // TODO: handle empty frame
                        } else if (frame.IsCorrupt){
                            // TODO: handle corrupt frame
                        } else if (frame.IsGreyscale){
                            // TODO: handle greyscale frame
                        } else {
                            // frame is normal
                            frames++;
                            points = points + frame.Count;
                        }                        
                        frame.Free();
                        frame = null;
                        frame = cam.GetFrame(0);
                    }
                }                
                // TODO: deal with input

                
                
                
            }                
        }
    }
}
It doesn't stutter or stop. goes on and on and on. so perhaps I'll just keep moving this direction.

I'll see if I can get my XP machine to run some of these examples and perhaps it will shed some light.
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Problem with getting frames in C#

Post by beckdo »

That does sound a little unusual. I ran the .Net 3.0 sample without issue, full frame rate and everything appeared to run properly.
Post Reply