473,490 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Motion Tracking Auto Turret

13 New Member
source code: <link removed>
comcast wont allow .rar (because they suck) so you have to right-click save page as and rename to .rar. i tested this twice and it works fine.

this motion detector has 2 filters, edges and rectangles. this is concerning the edges filter only, it compares two bitmaps (converted to grayscale), gets a list of x and y coordinates, and draws tiny rectangles at each coordinate which represent the difference between the 2 images (motion).

problem 1:
what i've been trying to do for a week now is create a method that takes that same x and y coordinate list, draws a rectangle of a different color on the AVERAGE of the coordinate list. it essentially creates a single target representing the average location of motion and displays it along with the original edges filter.

problem 2:
once that is done the next step would be to output that target coordinate to a mini-SSC servo controller (translated to servo angles) that the user would calibrate in a user interface.
Jan 31 '08 #1
8 3189
David24
13 New Member
source code: <link removed>
comcast wont allow .rar (because they suck) so you have to right-click save page as and rename to .rar. i tested this twice and it works fine.

this motion detector has 2 filters, edges and rectangles. this is concerning the edges filter only, it compares two bitmaps (converted to grayscale), gets a list of x and y coordinates, and draws tiny rectangles at each coordinate which represent the difference between the 2 images (motion).

problem 1:
what i've been trying to do for a week now is create a method that takes that same x and y coordinate list, draws a rectangle of a different color on the AVERAGE of the coordinate list. it essentially creates a single target representing the average location of motion and displays it along with the original edges filter.

problem 2:
once that is done the next step would be to output that target coordinate to a mini-SSC servo controller (translated to servo angles) that the user would calibrate in a user interface.
how's anybody supposed to help me if you guys remove the link to the source code? that's absolutely asinine..
Jan 31 '08 #2
Ganon11
3,652 Recognized Expert Specialist
It's part of our policy - you can read it in full if you follow the Help link at the top of the site.

If you are having issues with a specific section of code, please post it here - don't make users download a zip/rar file to help you.
Jan 31 '08 #3
David24
13 New Member
It's part of our policy - you can read it in full if you follow the Help link at the top of the site.

If you are having issues with a specific section of code, please post it here - don't make users download a zip/rar file to help you.
if i were an experienced programmer i would want the whole solution so i could actually test my modifications for functionality...that's fine though, i'll post the code. now, OF COURSE, the ENTIRE code needs to be posted because anything less would hinder comprehension. so instead of a simple post with a link to the source code, here's the annoying, tacky, eleventybillion page long code pasted to this post.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections;
  3. using System.Drawing;
  4. using System.Drawing.Imaging;
  5.  
  6. namespace VideoCapture
  7. {
  8.     public class ImageProcessing
  9.     {
  10.         //autogenerated Constructor - does nothing
  11.         private ImageProcessing( )
  12.         {
  13.         }
  14.         //Method AnalyzeImageWithEdges returns newImage (or null)
  15.         public static Bitmap AnalyzeImageWithEdges(
  16.             Bitmap originalImage,
  17.             Bitmap newImage )
  18.         {
  19.             if( originalImage == null || newImage == null )
  20.             {
  21.                 return null;
  22.             }
  23.  
  24.  
  25.             //half-size the originalImage
  26.             originalImage =
  27.                 ResizeImage(
  28.                     originalImage,
  29.                     originalImage.Height / 2,
  30.                     originalImage.Width / 2 );
  31.             //half-size the newImage
  32.             newImage =
  33.                 ResizeImage(
  34.                     newImage,
  35.                     newImage.Height / 2,
  36.                     newImage.Width / 2);
  37.  
  38.             //convert originalImage to grayscale
  39.             Bitmap grayedOriginalImage = GetGrayScaledImage(originalImage);
  40.             //convert newImage to grayscale
  41.             Bitmap grayedNewImage = GetGrayScaledImage(newImage);
  42.  
  43.             CoordinateList coordinateList =
  44.                 GetImageDifference(
  45.                     grayedOriginalImage,
  46.                     grayedNewImage);
  47.  
  48.             //draw lines for the edges filter
  49.             if( coordinateList.CalculateEdges().Length > 0 )
  50.             {
  51.                 using( Graphics graphics = Graphics.FromImage( newImage ) )
  52.                 {
  53.                     graphics.DrawRectangles(
  54.                         new Pen( Color.Red, 1 ),
  55.                         coordinateList.CalculateEdges() );
  56.                 }
  57.             }
  58.  
  59.             grayedOriginalImage.Dispose();
  60.             grayedOriginalImage = null;
  61.  
  62.             grayedNewImage.Dispose();
  63.             grayedNewImage = null;
  64.  
  65.             return newImage;
  66.         }
  67.  
  68.         //Method AnalyzeImageWithRectangles returns newImage (or null)
  69.         public static Bitmap AnalyzeImageWithRectangles(
  70.             Bitmap originalImage,
  71.             Bitmap newImage )
  72.         {
  73.             if (originalImage == null || newImage == null)
  74.             {
  75.                 return null;
  76.             }
  77.  
  78.             originalImage =
  79.                 ResizeImage(
  80.                     originalImage,
  81.                     originalImage.Height / 2,
  82.                     originalImage.Width / 2);
  83.  
  84.             newImage =
  85.                 ResizeImage(
  86.                     newImage,
  87.                     newImage.Height / 2,
  88.                     newImage.Width / 2);
  89.  
  90.             Bitmap grayedOriginalImage = GetGrayScaledImage(originalImage);
  91.             Bitmap grayedNewImage = GetGrayScaledImage(newImage);
  92.  
  93.             CoordinateList coordinateList =
  94.                 GetImageDifference( 
  95.                     grayedOriginalImage,
  96.                     grayedNewImage );
  97.  
  98.             if ( coordinateList.CalculateRectangles().Length > 0 )
  99.             {
  100.                 using( Graphics graphics = Graphics.FromImage( newImage ) )
  101.                 {
  102.                     graphics.DrawRectangles(
  103.                         new Pen( Color.BlueViolet, 1 ),
  104.                         coordinateList.CalculateRectangles() );
  105.                 }
  106.             }
  107.  
  108.             grayedOriginalImage.Dispose();
  109.             grayedOriginalImage = null;
  110.  
  111.             grayedNewImage.Dispose();
  112.             grayedNewImage = null;
  113.  
  114.             return newImage;
  115.         }
  116.  
  117.         //Method GetGrayScaledImage returns resultingBitmap
  118.         private static Bitmap GetGrayScaledImage( Bitmap originalImage )
  119.         {
  120.             Bitmap resultingBitmap =
  121.                 new Bitmap( 
  122.                     originalImage.Width, 
  123.                     originalImage.Height, 
  124.                     PixelFormat.Format32bppArgb );
  125.  
  126.             BitmapData originalData =
  127.                 originalImage.LockBits(
  128.                     new Rectangle( 
  129.                         0, 
  130.                         0, 
  131.                         originalImage.Width, 
  132.                         originalImage.Height ),
  133.                     ImageLockMode.ReadOnly,
  134.                     PixelFormat.Format32bppArgb );
  135.  
  136.             BitmapData resultingData =
  137.                 resultingBitmap.LockBits(
  138.                     new Rectangle( 
  139.                         0, 
  140.                         0, 
  141.                         resultingBitmap.Width, 
  142.                         resultingBitmap.Height ),
  143.                     ImageLockMode.ReadOnly,
  144.                     PixelFormat.Format32bppArgb );
  145.  
  146.             int newPixel = 0;
  147.  
  148.             unsafe
  149.             {
  150.                 byte* originalPointer = ( byte* )originalData.Scan0;
  151.                 byte* resultingPointer = ( byte* )resultingData.Scan0;
  152.  
  153.                 for( int yCoordinate = 0; yCoordinate < originalData.Height; ++yCoordinate )
  154.                 {
  155.                     for( int xCoordinate = 0; xCoordinate < originalData.Width; ++xCoordinate )
  156.                     {
  157.                         newPixel = 
  158.                             ( originalPointer[ 0 ] + 
  159.                             originalPointer[ 1 ] + 
  160.                             originalPointer[ 2 ] ) / 3;
  161.  
  162.                         resultingPointer[ 0 ] = ( byte )newPixel;     /* Blue   */
  163.                         resultingPointer[ 1 ] = ( byte )newPixel;     /* Green  */
  164.                         resultingPointer[ 2 ] = ( byte )newPixel;     /* Red    */
  165.                         resultingPointer[ 3 ] = originalPointer[ 3 ]; /* Alpha  */
  166.  
  167.                         originalPointer += 4;
  168.                         resultingPointer += 4;
  169.                     }
  170.  
  171.                     originalPointer += 
  172.                         originalData.Stride - ( originalData.Width * 4 );
  173.  
  174.                     resultingPointer += 
  175.                         resultingData.Stride - ( resultingData.Width * 4 );
  176.                 }
  177.             }
  178.  
  179.             resultingBitmap.UnlockBits( resultingData );
  180.             originalImage.UnlockBits( originalData );
  181.  
  182.             return resultingBitmap;
  183.         }
  184.  
  185.         //Method GetImageDifference returns coordinateList
  186.         private static CoordinateList GetImageDifference( Bitmap originalImage, Bitmap newImage )
  187.         {
  188.             Bitmap resultingBitmap =
  189.                 new Bitmap( 
  190.                     originalImage.Width, 
  191.                     originalImage.Height, 
  192.                     PixelFormat.Format32bppArgb );
  193.  
  194.             BitmapData originalData = 
  195.                 originalImage.LockBits( 
  196.                     new Rectangle( 
  197.                         0, 
  198.                         0, 
  199.                         originalImage.Width, 
  200.                         originalImage.Height ),
  201.                     ImageLockMode.ReadOnly,
  202.                     PixelFormat.Format24bppRgb );
  203.  
  204.             BitmapData newData =
  205.                 newImage.LockBits(
  206.                     new Rectangle( 
  207.                         0, 
  208.                         0, 
  209.                         newImage.Width, 
  210.                         newImage.Height ),
  211.                     ImageLockMode.ReadOnly,
  212.                     PixelFormat.Format24bppRgb );
  213.  
  214.             BitmapData resultingData =
  215.                 resultingBitmap.LockBits(
  216.                     new Rectangle( 
  217.                         0, 
  218.                         0, 
  219.                         resultingBitmap.Width, 
  220.                         resultingBitmap.Height ),
  221.                     ImageLockMode.WriteOnly,
  222.                     PixelFormat.Format24bppRgb );
  223.  
  224.             CoordinateList coordinateList = new CoordinateList();
  225.  
  226.             unsafe
  227.             {
  228.                 byte* originalPointer = ( byte* )originalData.Scan0;
  229.                 byte* newPointer = ( byte* )newData.Scan0;
  230.                 byte* resultingPointer = ( byte* )resultingData.Scan0;
  231.  
  232.                 for( int yCoordinate = 0; yCoordinate < originalData.Height; ++yCoordinate )
  233.                 {
  234.                     for( int xCoordinate = 0; xCoordinate < originalData.Width * 3; ++xCoordinate )
  235.                     {
  236.                         int originalPixel = 
  237.                             ( originalPointer[ 0 ] + 
  238.                             originalPointer[ 1 ] + 
  239.                             originalPointer[ 2 ] );
  240.  
  241.                         int newPixel =
  242.                             ( newPointer[ 0 ] + 
  243.                             newPointer[ 1 ] + 
  244.                             newPointer[ 2 ] );
  245.  
  246.                         if( newPixel > originalPixel + 140 || 
  247.                             newPixel < originalPixel - 140 )
  248.                         {
  249.                             resultingPointer[ 0 ] = 0;
  250.  
  251.                             coordinateList.Add(
  252.                                 new CoordinateList.PointOfInterest( 
  253.                                     xCoordinate / 3, 
  254.                                     yCoordinate ) );
  255.                         }
  256.                         else
  257.                         {
  258.                             resultingPointer[ 0 ] = 255;
  259.                         }
  260.  
  261.                         ++originalPointer;
  262.                         ++newPointer;
  263.                         ++resultingPointer;
  264.                     }
  265.  
  266.                     originalPointer += 
  267.                         originalData.Stride - ( originalData.Width * 3 );
  268.  
  269.                     newPointer += 
  270.                         newData.Stride - ( newData.Width * 3 );
  271.  
  272.                     resultingPointer += 
  273.                         resultingData.Stride - ( resultingData.Width * 3 );
  274.                 }
  275.             }
  276.  
  277.             resultingBitmap.UnlockBits( resultingData );
  278.             newImage.UnlockBits( newData );
  279.             originalImage.UnlockBits( originalData );
  280.  
  281.             resultingBitmap.Dispose();
  282.             resultingBitmap = null;
  283.  
  284.             return coordinateList;
  285.         }
  286.  
Jan 31 '08 #4
Ganon11
3,652 Recognized Expert Specialist
Rest of the code:

Expand|Select|Wrap|Line Numbers
  1.         //Method ResizeImage returns resultingImage
  2.         private static Bitmap ResizeImage( 
  3.             Bitmap bitmap, 
  4.             int height, 
  5.             int width )
  6.         {
  7.             Bitmap resultingImage  = new Bitmap( width, height );
  8.  
  9.             using( Graphics graphics = 
  10.                 Graphics.FromImage( ( Image )resultingImage) )
  11.             {
  12.                 graphics.DrawImage(bitmap, 0, 0, width, height);
  13.             }
  14.  
  15.             return resultingImage;
  16.         }
  17.  
  18.         #region CoordinateList Inner-Class
  19.  
  20.         public class CoordinateList : CollectionBase
  21.         {
  22.             public PointOfInterest this[ int index ]
  23.             {
  24.                 get { return ( PointOfInterest )this.List[ index ]; }
  25.             }
  26.             //Method Add
  27.             public void Add( PointOfInterest pointOfInterest )
  28.             {
  29.                 this.List.Add( pointOfInterest );
  30.             }
  31.  
  32.             //Method CalculateEdges returns rectangles
  33.             public Rectangle[] CalculateEdges( )
  34.             {
  35.                 CoordinateList coordinateList = new CoordinateList();
  36.  
  37.                 PointOfInterest previousPointOfInterest =
  38.                     new PointOfInterest( -1, -1 );
  39.  
  40.                 int rowCounter = 0;
  41.  
  42.                 foreach( PointOfInterest pointOfInterest in this.List )
  43.                 {
  44.                     if( ( ( pointOfInterest.XCoordinate > 
  45.                             previousPointOfInterest.XCoordinate + THRESHOLD ||
  46.                         pointOfInterest.XCoordinate < 
  47.                             previousPointOfInterest.XCoordinate - THRESHOLD ) &&
  48.                         ( pointOfInterest.YCoordinate > 
  49.                             previousPointOfInterest.YCoordinate + THRESHOLD ||
  50.                         pointOfInterest.YCoordinate < 
  51.                             previousPointOfInterest.YCoordinate - THRESHOLD ) ) ||
  52.                         rowCounter == 2 )
  53.                     {
  54.                         coordinateList.Add( pointOfInterest );
  55.  
  56.                         rowCounter = 0;
  57.                     }
  58.  
  59.                     if( pointOfInterest.YCoordinate != 
  60.                         previousPointOfInterest.YCoordinate )
  61.                     {
  62.                         ++rowCounter;
  63.                     }
  64.  
  65.                     previousPointOfInterest =
  66.                         new PointOfInterest(
  67.                             pointOfInterest.XCoordinate, 
  68.                             pointOfInterest.YCoordinate );
  69.                 }
  70.  
  71.                 //int x = coordinateList.XCoordinate / coordinateList.XCoordinate.Count;
  72.                 //int y = coordinateList.YCoordinate / coordinateList.XCoordinate.Count;
  73.                 //target = new Rectangle(x, y, 10, 10);
  74.                 //coordinateList.Add(target);
  75.  
  76.                 Rectangle[] rectangles =
  77.                     new Rectangle[ coordinateList.Count ];
  78.  
  79.                 //edges filter
  80.                 for( int i = 0; i <= ( coordinateList.Count - 1 ); ++i )
  81.                 {
  82.                     rectangles[ i ] =
  83.                         new Rectangle(
  84.                             coordinateList[ i ].XCoordinate,
  85.                             coordinateList[ i ].YCoordinate,
  86.                             1,
  87.                             1);
  88.                 }
  89.  
  90.                 return rectangles;
  91.             }
  92.             //Method CalculateRectangles returns rectangles
  93.             public Rectangle[] CalculateRectangles( )
  94.             {
  95.                 CoordinateList coordinateList = new CoordinateList();
  96.  
  97.                 PointOfInterest previousPointOfInterest =
  98.                     new PointOfInterest( -1, -1 );
  99.  
  100.                 PointOfInterest pointOfInterest = 
  101.                     new PointOfInterest( -1, -1 );
  102.  
  103.                 foreach( PointOfInterest existingPointOfInterest in this.List )
  104.                 {
  105.                     if( ( existingPointOfInterest.XCoordinate > 
  106.                             previousPointOfInterest.XCoordinate + THRESHOLD ||
  107.                         existingPointOfInterest.XCoordinate < 
  108.                             previousPointOfInterest.XCoordinate - THRESHOLD ) &&
  109.                         ( existingPointOfInterest.YCoordinate > 
  110.                             previousPointOfInterest.YCoordinate + THRESHOLD ||
  111.                         existingPointOfInterest.YCoordinate < 
  112.                             previousPointOfInterest.YCoordinate - THRESHOLD ) )
  113.                     {
  114.                         pointOfInterest = existingPointOfInterest;
  115.                     }
  116.  
  117.                     if( existingPointOfInterest.YCoordinate != 
  118.                         previousPointOfInterest.YCoordinate )
  119.                     {
  120.                         pointOfInterest.Height = 
  121.                             previousPointOfInterest.YCoordinate - 
  122.                             pointOfInterest.YCoordinate;
  123.  
  124.                         pointOfInterest.Width = 
  125.                             previousPointOfInterest.XCoordinate - 
  126.                             pointOfInterest.XCoordinate;
  127.  
  128.                         coordinateList.Add( pointOfInterest );
  129.                     }
  130.  
  131.                     previousPointOfInterest =
  132.                         new PointOfInterest(
  133.                             existingPointOfInterest.XCoordinate,
  134.                             existingPointOfInterest.YCoordinate );
  135.                 }
  136.  
  137.                 Rectangle[] rectangles = 
  138.                     new Rectangle[ coordinateList.Count ];
  139.  
  140.                 for( int i = 0; i <= ( coordinateList.Count - 1 ); ++i )
  141.                 {
  142.                     rectangles[ i ] =
  143.                         new Rectangle( 
  144.                             coordinateList[ i ].XCoordinate,
  145.                             coordinateList[ i ].YCoordinate,
  146.                             coordinateList[ i ].Width, 
  147.                             coordinateList[ i ].Height );
  148.                 }
  149.  
  150.                 return rectangles;
  151.             }
  152.  
  153.             //Method SortByYCoordinateAscending
  154.             public void SortByXCoordinateAscending( )
  155.             {
  156.                 IComparer sorter = new SortByXCoordinate();
  157.                 InnerList.Sort( sorter );
  158.             }
  159.  
  160.             //Method SortByYCoordinateAscending
  161.             public void SortByYCoordinateAscending( )
  162.             {
  163.                 IComparer sorter = new SortByYCoordinate();
  164.                 InnerList.Sort( sorter );
  165.             }
  166.  
  167.             //Method GetTarget (i created)
  168.             /*public static Rectangle GetTarget()
  169.             {
  170.                 int x = coordinateList.XCoordinate / coordinateList.XCoordinate.Count;
  171.                 int y = coordinateList.YCoordinate / coordinateList.XCoordinate.Count;
  172.                 target = new Rectangle(x, y, 10, 10);
  173.                 return target;
  174.             }*/
  175.  
  176.             private const int THRESHOLD = 10;
  177.  
  178.             #region PointOfInterest Inner-Class
  179.  
  180.             public class PointOfInterest
  181.             {
  182.                 //Property PointOfInterest
  183.                 public PointOfInterest( int xCoordinate, int yCoordinate )
  184.                 {
  185.                     this.xCoordinate = xCoordinate;
  186.                     this.yCoordinate = yCoordinate;
  187.                 }
  188.  
  189.                 #region Attributes
  190.                 //Property height returns height
  191.                 public int Height
  192.                 {
  193.                     get { return height; }
  194.                     set { height = value; }
  195.                 }
  196.                 //Property Width returns width
  197.                 public int Width
  198.                 {
  199.                     get { return width; }
  200.                     set { width = value; }
  201.                 }
  202.                 //Property XCoordinate returns xCoordinate
  203.                 public int XCoordinate
  204.                 {
  205.                     get { return xCoordinate; }
  206.                     set { xCoordinate = value; }
  207.                 }
  208.                 //Property YCoordinate returns yCoordinate
  209.                 public int YCoordinate
  210.                 {
  211.                     get { return yCoordinate; }
  212.                     set { yCoordinate = value; }
  213.                 }
  214.  
  215.                 #endregion
  216.  
  217.                 private int height = 0;
  218.                 private int width = 0;
  219.                 private int xCoordinate = -1;
  220.                 private int yCoordinate = -1;
  221.             }
  222.  
  223.             #endregion
  224.  
  225.             #region Sorting Inner-Classes
  226.  
  227.             public class SortByXCoordinate : IComparer
  228.             {
  229.                 // Method Compare returns ic1.CompareTo( ic2 )
  230.                 public int Compare( object compare1, object compare2 )
  231.                 {
  232.                     PointOfInterest pointOfInterest1 = 
  233.                         ( PointOfInterest )compare1;
  234.  
  235.                     IComparable ic1 = 
  236.                         ( IComparable )pointOfInterest1.XCoordinate;
  237.  
  238.                     PointOfInterest pointOfInterest2 =
  239.                         ( PointOfInterest )compare2;
  240.  
  241.                     IComparable ic2 =
  242.                         ( IComparable )pointOfInterest2.XCoordinate;
  243.  
  244.                     return ic1.CompareTo( ic2 );
  245.                 }
  246.             }
  247.  
  248.             public class SortByYCoordinate : IComparer
  249.             {
  250.                 //Method Compare returns ic1.CompareTo( ic2 )
  251.                 public int Compare( object compare1, object compare2 )
  252.                 {
  253.                     PointOfInterest pointOfInterest1 =
  254.                         ( PointOfInterest )compare1;
  255.  
  256.                     IComparable ic1 =
  257.                         ( IComparable )pointOfInterest1.YCoordinate;
  258.  
  259.                     PointOfInterest pointOfInterest2 =
  260.                         ( PointOfInterest )compare2;
  261.  
  262.                     IComparable ic2 =
  263.                         ( IComparable )pointOfInterest2.YCoordinate;
  264.  
  265.                     return ic1.CompareTo( ic2 );
  266.                 }
  267.             }
  268.  
  269.             #endregion
  270.         }
  271.  
  272.         #endregion
  273.     }
  274. }
Jan 31 '08 #5
Ganon11
3,652 Recognized Expert Specialist
if i were an experienced programmer i would want the whole solution so i could actually test my modifications for functionality...that's fine though, i'll post the code. now, OF COURSE, the ENTIRE code needs to be posted because anything less would hinder comprehension. so instead of a simple post with a link to the source code, here's the annoying, tacky, eleventybillion page long code pasted to this post.
I agree, it's not a perfect solution. However, imagine this situation:

Poster A comes to the site and says "I need help, here's the source code and an executable" or whatever. Helper B comes, downloads the source code or executable or whatever, and tries to use it. Whoops! Its not a friendly program like Poster A said - it's actually a virus. Now Helper B is screwed, as well as Helper C and D, Moderator E, and anyone else who wanted to help out.

If we see your code on the site, in a post, it can't do anything to our computer. We can now help you without having to worry about "Is this guy some lying jerk who wants to kill my computer?"

So however annoying it is, it's for the protection of users like you. And, to be frank, if you don't like it, feel free to find help elsewhere. We have come up with the posting guidelines for a specific reason. If you'd like clarification, or have an honest issue with a part of the guidelines, feel free to raise them (the Miscellaneous Discussions section is the best place for this), but please don't just complain about them.

MODERATOR
Jan 31 '08 #6
David24
13 New Member
there's the code. we'll see if anyone can solve the problem.. (line 167 is the method i tried to create (which doesn't work))
Jan 31 '08 #7
oler1s
671 Recognized Expert Contributor
if i were an experienced programmer i would want the whole solution so i could actually test my modifications for functionality
No. We will make suggestions for you, and guide you in the right direction, but we will not repeatedly test and debug your code to get you ahead. That is work you must do on your own. Our suggestions will not necessarily be copy-paste answers either. Sorry to burst your bubble, about what to expect on programmer forums.

What we actually want is a decent description of the problem. You described what you are working on, which is good. Unfortunately, you failed to describe what obstacle you have reached. You mentioned the two problems you were working on. It elicits a, "so what" from us. So? What's the problem in what you're working on? Is code not compiling? Runtime errors? Clueless how to approach the problem? What?

Moreover, you have effectively dumped a large block of code, which is useless. The entire code is not in question, is it? It's a specific portion of the code that doesn't work. Moreover, "doesn't work" is a useless comment for programmers. Great. Is it not working because when the code runs, your lights in your room flicker? No? Something happens at runtime? What did you see? Not at runtime? Can't get it to compile? What was the error?

You want good responses, you need to isolate the problem on your own, as best as you can. If you can't, describe your observations, and ask how you might narrow down the problem. See Eric Raymond's article on what ideal questions are like.

You need to be precise and informative. This end is not served by simply dumping huge volumes of code or data into a help request. If you have a large, complicated test case that is breaking a program, try to trim it and make it as small as possible.

This is useful for at least three reasons. One: being seen to invest effort in simplifying the question makes it more likely you'll get an answer, Two: simplifying the question makes it more likely you'll get a useful answer. Three: In the process of refining your bug report, you may develop a fix or workaround yourself.
Maybe one of us will get around to helping you. Most likely, you'll get little information. It's a large code dump, effectively, with no help on your part in trying to find the solution. Trim it down, and give us more precise details, please.
Jan 31 '08 #8
David24
13 New Member
...
no problem.

Expand|Select|Wrap|Line Numbers
  1.             //Method GetTarget (i created)
  2.             public static Rectangle GetTarget()
  3.             {
  4.                 //find the average x coordinate
  5.                 int x = coordinateList.XCoordinate / coordinateList.XCoordinate.Count;
  6.                 //find the average y coordinate
  7.                 int y = coordinateList.YCoordinate / coordinateList.XCoordinate.Count;
  8.                 //create a rectangle 10by10 pixels wide at the average location of x and y and store it as target
  9.                 target = new Rectangle(x, y, 10, 10);
  10.                 //return that coordinate
  11.                 return target;
  12.             }
  13.  
this can be found on line 167

compile error:
The name 'coordinateList' does not exist in the current context
The name 'target' does not exist in the current context

this was my attempt at a method for solving problem1.
there are likely several things wrong here. the method may be inside the wrong class, it doesn't refer to the array coordinateList correctly, or i may need to create an object instance of the class the coordinateList array is from... i dunno. like i said, i tried for at least a week to solve this with no luck.
Feb 1 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
7926
by: gsb | last post by:
I track the mouse location like this code: function mousePos(e) { var p = new Object(); if(e) { p.x = e.pageX; p.y = e.pageY; } else { p.x = event.x; p.y = event.y; } ... (show) }...
2
3977
by: User10 | last post by:
Can some one provide an algorithm for motion detection between two jpeg frames? Or can you provide a more appropriate group to post this on? Thanks!
5
3991
by: dee | last post by:
My wife is school secretary who inherited the job of tracking about 100 keys to about 150 school employees for thee next school year. Their current system, comprised of 2 non connected...
0
2630
by: krishna81m | last post by:
Could some one please explain why the session is not being maintained when I am doing a forward in a servlet after setting a cookie. I am even unable to set session attributes or parameters and...
4
3645
by: David24 | last post by:
It's on YouTube and the video id is aNTH_8IA0XQ or you can just search for "Motion Tracking Auto Turret" Check it out and let me know what you think.. The Video demonstrates how the Turret will...
1
2010
by: valy | last post by:
hi guys, do y'all have any idea about writing a function to calculate the amount of white pixels on a difference image, and if the white amount is >= the threshold value then the image is count as...
1
7406
joedeene
by: joedeene | last post by:
Hello all, I am using Macromedia Flash Professional 8 in this example of a simple way to use motion tweens. Ok here goes... Directions: A. Preparation 1.) Start the Flash program. Once...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.