Пример #1
0
        public void addFrame(kFrame frame)
        {
            //System.Console.WriteLine("New frame");

            try
            {
                //reference table code
                //"CREATE TABLE frameManager (session INTEGER, frame INTEGER, object VARCHAR(20), accept VARCHAR(20), x DOUBLE, y DOUBLE, z DOUBLE, PRIMARY KEY(session, frame, object));";
                queries = "INSERT INTO frameManager (session, frame, object, accept, x, y, z) VALUES (@session, @frame, @object, @accept, @x, @y, @z);";
                sqCmd = new SQLiteCommand(queries, sqConnection);
                sqCmd.Parameters.AddWithValue("@session", frame.getSession());
                sqCmd.Parameters.AddWithValue("@frame", frame.getFrame());
                sqCmd.Parameters.AddWithValue("@object", frame.getObject());
                sqCmd.Parameters.AddWithValue("@accept", frame.getAccept());
                sqCmd.Parameters.AddWithValue("@x", frame.getX());
                sqCmd.Parameters.AddWithValue("@y", frame.getY());
                sqCmd.Parameters.AddWithValue("@z", frame.getZ());
                sqCmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }

            //System.Console.WriteLine("New frame END");
        }
Пример #2
0
        private void InsertDB_Collected(string str, string is_accept, float x, float y, float z)
        {
            //System.Console.WriteLine("Inserting Collected Values for " + str);

            kFrame frame = new kFrame(sessionID, frame_counter, str, is_accept, x, y, z);
            sessionData.addFrame(frame);

            //System.Console.WriteLine("Collected Data Inserted");
            //sessionData.printFrames(sessionID);
        }
Пример #3
0
        private void InsertDB_Calibrate(string str, float x, float y, float z)
        {
            System.Console.WriteLine("Inserting Calibration Values for " + str);

            kFrame boxframe = new kFrame(sessionID, 0, str, null, x, y, z);
            sessionData.createBox(boxframe);

            System.Console.WriteLine("Calibration Data Inserted");
            //sessionData.printFrames(sessionID);
        }
Пример #4
0
        /* pointless function with zero use so far but left in code
        public kFrame getObjkFrame(int framenum, int sessionid, string obj)
        {
            System.Console.WriteLine("Get frame for obj" + obj.ToString());

            kFrame frame = null;

            try
            {
                queries = "SELECT * FROM frameManager WHERE frame=@frame, and session=@sessionid, and object=@object";
                sqCmd = new SQLiteCommand(queries, sqConnection);
                sqCmd.Parameters.AddWithValue("@frame", framenum);
                sqCmd.Parameters.AddWithValue("@sessionid", sessionid);
                sqCmd.Parameters.AddWithValue("@object", obj);
                sqDatareader = sqCmd.ExecuteReader();

                sqDatareader.Read();

                frame = new kFrame((int)sqDatareader["session"], (int)sqDatareader["frame"], (string)sqDatareader["object"], (string)sqDatareader["accept"], (double)sqDatareader["x"], (double)sqDatareader["y"], (double)sqDatareader["z"]);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }

            System.Console.WriteLine("Return found frame");

            return frame;
        }
        */
        //create the frame for acceptable movement, highly recommended to change range multipliers with further testing
        public void createBox(kFrame frame)
        {
            //System.Console.WriteLine("Creating box parameter");

            try
            {
                //reference for table code
                //"CREATE TABLE boxManager (session INTEGER, object VARCHAR(20), minx DOUBLE, miny DOUBLE, minz DOUBLE, maxx DOUBLE, maxy DOUBLE, maxz double, PRIMARY KEY (session, object));";
                queries = "INSERT INTO boxManager (session, object, minx, miny, minz, maxx, maxy, maxz) VALUES (@session, @object, @minx, @miny, @minz, @maxx, @maxy, @maxz);";
                sqCmd = new SQLiteCommand(queries, sqConnection);
                sqCmd.Parameters.AddWithValue("@session", frame.getSession());
                sqCmd.Parameters.AddWithValue("@object", frame.getObject());
                sqCmd.Parameters.AddWithValue("@minx", frame.getX() * 1 / 4);
                sqCmd.Parameters.AddWithValue("@miny", frame.getY() * 1 / 4);
                sqCmd.Parameters.AddWithValue("@minz", frame.getZ() * 1 / 4);
                sqCmd.Parameters.AddWithValue("@maxx", frame.getX() * 2);
                sqCmd.Parameters.AddWithValue("@maxy", frame.getY() * 2);
                sqCmd.Parameters.AddWithValue("@maxz", frame.getZ() * 2);
                sqCmd.ExecuteNonQuery();

            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }

            //System.Console.WriteLine("Box parameters inserted");
        }
Пример #5
0
        public List<kFrame> getSkeleton(int sessionid, int framenum)
        {
            System.Console.WriteLine("Get frame for session #" + sessionid + " and frame #" + framenum);

            //create list of kframes to return
            List<kFrame> frameValues = new List<kFrame>();

            try
            {
                //create reader object to read rows
                queries = "SELECT * FROM frameManager WHERE frame=@frame, and session=@sessionid";
                sqCmd = new SQLiteCommand(queries, sqConnection);
                sqCmd.Parameters.AddWithValue("@frame", framenum);
                sqCmd.Parameters.AddWithValue("@sessionid", sessionid);
                sqDatareader = sqCmd.ExecuteReader();

                //read while rows exist with data
                while(sqDatareader.Read())
                {
                    kFrame frame = new kFrame((int)sqDatareader["session"], (int)sqDatareader["frame"], (string)sqDatareader["object"], (string)sqDatareader["accept"], (double)sqDatareader["x"], (double)sqDatareader["y"], (double)sqDatareader["z"]);
                    frameValues.Add(frame);
                }

            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }

            System.Console.WriteLine("Sucess. Returning found skeletal frame");

            return frameValues;
        }
Пример #6
0
        public List<kFrame> getSession(int sessionid)
        {
            //gets all frames for a specified sessionId
            System.Console.WriteLine("Get ALL frames for session #" + sessionid);

            //return list of kframes
            List<kFrame> frameValues = new List<kFrame>();

            try
            {
                //create a reader object to read rows
                queries = "SELECT * FROM frameManager WHERE session=@sessionid";
                sqCmd = new SQLiteCommand(queries, sqConnection);
                sqCmd.Parameters.AddWithValue("@sessionid", sessionid);
                sqDatareader = sqCmd.ExecuteReader();

                //while a row exists with data
                while(sqDatareader.Read())
                {
                    //int fnum = (int)sqDatareader["frame"];
                    kFrame frame = new kFrame((int)sqDatareader["session"], (int)sqDatareader["frame"], (string)sqDatareader["object"], (string)sqDatareader["accept"], (double)sqDatareader["x"], (double)sqDatareader["y"], (double)sqDatareader["z"]);
                    frameValues.Add(frame);
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }

            System.Console.WriteLine("Sucess. Returning session frames");

            return frameValues;
        }