Page 3 of 7 FirstFirst 12345 ... LastLast
Results 51 to 75 of 162

Thread: Scar++

  1. #51
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Bobarkinator View Post
    I would be working more but I've been caught up in FindColorsSpiralTolerance, I can't figure it out
    , I committed it already (it is part of the new revision, 15). Basically I just used FindColorsTolerance then sorted out the colors after that (using the Pythagoreans theory). Might not be as fast as a real spiral, but shouldn't be too bad. (FindColorsTolerance will probably be faster then most Color Spirals, but the sort is what will make things take a bit longer then a real spiral)

  2. #52
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Finding the colours first then sorting should actually be faster as spiral searching first would require maybe thousands more calculations to be run as it makes the points to check
    Anyway, look forward to testing it out and I'll be sure to report any bugs etc.
    Edit: Maybe add the link on the first post? Took me a while to find it hiding on the second page
    Edit2: What compiler are you using? Just asking
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  3. #53
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    MinGW


  4. #54
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    Finding the colours first then sorting should actually be faster as spiral searching first would require maybe thousands more calculations to be run as it makes the points to check
    Anyway, look forward to testing it out and I'll be sure to report any bugs etc.
    Edit: Maybe add the link on the first post? Took me a while to find it hiding on the second page
    Edit2: What compiler are you using? Just asking
    Well, it really depends on the method used. Spiral finding follows a somewhat linear path where as sorting is more logarithmic. So when dealing with lots of points (Found points mind you) spiral searching will be faster. But when you deal with only a few, I believe doing a sort will be somewhat quicker.

    One thing you have to remember with sorting is that to do it properly you have to take a square root of a square, that can be somewhat cumbersome at times. I have tried to minimize the number of times this is done (only one pass per all the points) but the damage is still done.

    Also, the results are somewhat different, mine returns the results of a circular spiral rather then a square one, I don't know that that makes much of a difference though. (The reason for using this function would be to have the first point close to the middle)

    I don't know that this function will be used too much as FindColorsTolerance would require less work and give you the same data in just a different order.

    Oh, and I updated the front page, it was a good suggestion .

  5. #55
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    extraFuncs.cpp

    - tBoxCompair: Spelled wrong. tBoxCompare is correct.

    - Greater: it returns the Greatest number, it should be named thus; 'greater' could be misleading as to the return type (seems more logical that it'd return a boolean, basically the same thing as >)

    - Lesser: See Greater.

    Little stuff. Hoping to experiment some tomorrow.

    EDIT:
    return (Mouse::IsLeftDown && LeftButton) || (Mouse::IsRightDown && !LeftButton);

    Not confused at all
    Interested in C# and Electrical Engineering? This might interest you.

  6. #56
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    I don't know if I understood it properly, but do you use GetPixel in FindColor? Isn 't there something faster (ScanLines)?
    Hup Holland Hup!

  7. #57
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    I don't know if I understood it properly, but do you use GetPixel in FindColor? Isn 't there something faster (ScanLines)?
    Honestly, we are trying to get everything to work right now. Tweaks will be made later. For example, FindColorsSpiralTolerance takes around 2 seconds or longer for 40,000 points in SCAR++, regular SCAR takes 15 ms. We will tweak it later.


  8. #58
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Smartzkid View Post
    extraFuncs.cpp

    - tBoxCompair: Spelled wrong. tBoxCompare is correct.

    - Greater: it returns the Greatest number, it should be named thus; 'greater' could be misleading as to the return type (seems more logical that it'd return a boolean, basically the same thing as >)

    - Lesser: See Greater.

    Little stuff. Hoping to experiment some tomorrow.

    EDIT:
    return (Mouse::IsLeftDown && LeftButton) || (Mouse::IsRightDown && !LeftButton);

    Not confused at all
    Dang it, I knew there would be some spelling errors in there, . As for the greater lesser thing, I would disagree with your grammatical logic.

    If I ask you which is greater 1 or 2, of course you would respond 2. If I ask you which is greatest 1 or 2, of course you would respond 2. Both are perfectly correct grammatically. To return a bool would be confusing, IMO (Why would you make such a short function for that anyways?). Greatest implies the biggest of a set while greater implies the bigger of a pair, but not necessarily the biggest in a set. if I did a greatest function I would probably pass it an array and then return the biggest number in the array.

  9. #59
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Bobarkinator View Post
    Honestly, we are trying to get everything to work right now. Tweaks will be made later. For example, FindColorsSpiralTolerance takes around 2 seconds or longer for 40,000 points in SCAR++, regular SCAR takes 15 ms. We will tweak it later.
    As you might have noticed, freddy tried to tweak his functions quite often.. But not always with the wanted result .
    Verrekte Koekwous

  10. #60
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mastaraymond View Post
    As you might have noticed, freddy tried to tweak his functions quite often.. But not always with the wanted result .
    in this case we are pretty sure whats going on in the background and how to change it so its a bit faster. But for now, if you look for a color and find over 40,000 points that are valid, then something is probably wrong with your script (IMO) the lower you go the faster the function will be.

  11. #61
    Join Date
    Mar 2007
    Posts
    107
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    well, this is kind of stupid but you could write ismousebutton down from smatrzkid's post as
    'return LeftButton?Mouse::IsLeftDown:Mouse::IsRightDown;' save like 10 bytes of source size lol

    edit:

    Quote Originally Posted by boberman View Post
    Well, it really depends on the method used. Spiral finding follows a somewhat linear path where as sorting is more logarithmic. So when dealing with lots of points (Found points mind you) spiral searching will be faster. But when you deal with only a few, I believe doing a sort will be somewhat quicker.

    One thing you have to remember with sorting is that to do it properly you have to take a square root of a square, that can be somewhat cumbersome at times. I have tried to minimize the number of times this is done (only one pass per all the points) but the damage is still done.

    Also, the results are somewhat different, mine returns the results of a circular spiral rather then a square one, I don't know that that makes much of a difference though. (The reason for using this function would be to have the first point close to the middle)

    I don't know that this function will be used too much as FindColorsTolerance would require less work and give you the same data in just a different order.

    Oh, and I updated the front page, it was a good suggestion .
    is this the code you are talking about??

    Code:
    void ColorFind::FindColorsSpiralTolerance(int x, int y, std::vector<POINT>& Points, int color,
    574 	                                          int xs, int ys, int xe, int ye, int Tolerance)
    575 	{
    576 	   int i = 0;
    577 	   int pointsSize;
    578 	   double* distances;
    579 	   
    580 	   ColorFind::FindColorsTolerance(Points, color, xs, ys, xe, ye, Tolerance);
    581 	   pointsSize = Points.size();
    582 	   
    583 	   distances = new double[pointsSize];
    584 	   
    585 	   for(int i = 0; i < pointsSize; ++i)
    586 	      distances[i] = sqrt(((Points[i].x - x) * (Points[i].x - x)) +
    587 	                          ((Points[i].y - y) * (Points[i].y - y)));
    588 	   
    589 	   i = 0;
    590 	   
    591 	   // Heap Sort, Yeay!
    592 	   while(i < pointsSize)
    593 	   {
    594 	      int j = i;
    595 	      double minDistance = 2000;
    596 	      int closestPoint;
    597 	      for (j = i; j < pointsSize; ++j)
    598 	      {
    599 	         if(distances[j] < minDistance)
    600 	         {
    601 	            closestPoint = j;
    602 	            minDistance = distances[j];
    603 	         }
    604 	      }
    605 	      std::swap(distances[i], distances[closestPoint]);
    606 	      std::swap(Points[i], Points[closestPoint]);
    607 	      ++i;
    608 	   }
    609 	   delete[] distances;
    610 	}
    well, first off dont allocate a bunch of doubles, ints, or unsigned is good enough because you don't really need to calculate the sqrt of all those pts.
    it is enough to know that if ((x1 - x2)^2 + (y2 - y2)^2) is greater than that of another pt then the sqrt will obviously be greater (plus more accuracy that way).

    edit 2:

    Code:
    	bool Keyboard::IsFunctionKeyDown(int Key)
    111 	{
    112 	   int newKey;
    113 	   
    114 	   switch (Key) // I wish there was a better way to do this, but alas none of
    115 	   {            // the key codes are in order :(
    116 	      case 0:
    117 	         newKey = VK_SHIFT;
    118 	         break;
    119 	      case 1:
    120 	         newKey = VK_CONTROL;
    121 	         break;
    122 	      case 2:
    123 	         newKey = VK_MENU;
    124 	         break;
    125 	      case 3:
    126 	         newKey = VK_LSHIFT;
    127 	         break;
    128 	      case 4:
    129 	         newKey = VK_LCONTROL;
    130 	         break;
    131 	      case 5:
    132 	         newKey = VK_LMENU;
    133 	         break;
    134 	      case 6:
    135 	         newKey = VK_RSHIFT;
    136 	         break;
    137 	      case 7:
    138 	         newKey = VK_RCONTROL;
    139 	         break;
    140 	      case 8:
    141 	         newKey = VK_RMENU;
    142 	         break;
    143 	      default:
    144 	         newKey = 0; 
    145 	   }
    146 	}
    well, isn't a better way to do a simple bin search? like this
    Code:
    	return
    	(x<5)?
    		((x<3)?
    			((x<2)?
    				((x<1)?
    					(VK_SHIFT):
    					(VK_CONTROL)):
    				(VK_MENU)):
    			((x<4)?
    				(VK_LSHIFT):
    				(VK_LCONTROL))):
    		((x<8)?
    			((x<7)?
    				((x<6)?
    					(VK_LMENU):
    					(VK_RSHIFT)):
    				(VK_RCONTROL)):
    			((x<9)?
    				(VK_RMENU):
    				(0)));
    erm? hope that works..(your probably saving at least 2 nanoseconds with that lol)

  12. #62
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by sherlockmeister View Post
    well, this is kind of stupid but you could write ismousebutton down from smatrzkid's post as
    'return LeftButton?Mouse::IsLeftDown:Mouse::IsRightDown;' save like 10 bytes of source size lol

    edit:



    is this the code you are talking about??

    Code:
    void ColorFind::FindColorsSpiralTolerance(int x, int y, std::vector<POINT>& Points, int color,
    574 	                                          int xs, int ys, int xe, int ye, int Tolerance)
    575 	{
    576 	   int i = 0;
    577 	   int pointsSize;
    578 	   double* distances;
    579 	   
    580 	   ColorFind::FindColorsTolerance(Points, color, xs, ys, xe, ye, Tolerance);
    581 	   pointsSize = Points.size();
    582 	   
    583 	   distances = new double[pointsSize];
    584 	   
    585 	   for(int i = 0; i < pointsSize; ++i)
    586 	      distances[i] = sqrt(((Points[i].x - x) * (Points[i].x - x)) +
    587 	                          ((Points[i].y - y) * (Points[i].y - y)));
    588 	   
    589 	   i = 0;
    590 	   
    591 	   // Heap Sort, Yeay!
    592 	   while(i < pointsSize)
    593 	   {
    594 	      int j = i;
    595 	      double minDistance = 2000;
    596 	      int closestPoint;
    597 	      for (j = i; j < pointsSize; ++j)
    598 	      {
    599 	         if(distances[j] < minDistance)
    600 	         {
    601 	            closestPoint = j;
    602 	            minDistance = distances[j];
    603 	         }
    604 	      }
    605 	      std::swap(distances[i], distances[closestPoint]);
    606 	      std::swap(Points[i], Points[closestPoint]);
    607 	      ++i;
    608 	   }
    609 	   delete[] distances;
    610 	}
    well, first off dont allocate a bunch of doubles, ints, or unsigned is good enough because you don't really need to calculate the sqrt of all those pts.
    it is enough to know that if ((x1 - x2)^2 + (y2 - y2)^2) is greater than that of another pt then the sqrt will obviously be greater (plus more accuracy that way).

    edit 2:

    Code:
    	bool Keyboard::IsFunctionKeyDown(int Key)
    111 	{
    112 	   int newKey;
    113 	   
    114 	   switch (Key) // I wish there was a better way to do this, but alas none of
    115 	   {            // the key codes are in order :(
    116 	      case 0:
    117 	         newKey = VK_SHIFT;
    118 	         break;
    119 	      case 1:
    120 	         newKey = VK_CONTROL;
    121 	         break;
    122 	      case 2:
    123 	         newKey = VK_MENU;
    124 	         break;
    125 	      case 3:
    126 	         newKey = VK_LSHIFT;
    127 	         break;
    128 	      case 4:
    129 	         newKey = VK_LCONTROL;
    130 	         break;
    131 	      case 5:
    132 	         newKey = VK_LMENU;
    133 	         break;
    134 	      case 6:
    135 	         newKey = VK_RSHIFT;
    136 	         break;
    137 	      case 7:
    138 	         newKey = VK_RCONTROL;
    139 	         break;
    140 	      case 8:
    141 	         newKey = VK_RMENU;
    142 	         break;
    143 	      default:
    144 	         newKey = 0; 
    145 	   }
    146 	}
    well, isn't a better way to do a simple bin search? like this
    Code:
    	return
    	(x<5)?
    		((x<3)?
    			((x<2)?
    				((x<1)?
    					(VK_SHIFT):
    					(VK_CONTROL)):
    				(VK_MENU)):
    			((x<4)?
    				(VK_LSHIFT):
    				(VK_LCONTROL))):
    		((x<8)?
    			((x<7)?
    				((x<6)?
    					(VK_LMENU):
    					(VK_RSHIFT)):
    				(VK_RCONTROL)):
    			((x<9)?
    				(VK_RMENU):
    				(0)));
    erm? hope that works..(your probably saving at least 2 nanoseconds with that lol)
    Ill be honest, I don't like using turinary operators what you gain in potential speed (I don't even know that there is a gain) you loose in readability and maintainability. Speed isn't always key (Especially with simple functions that won't be called very often).

    Though, you make a good point with the sqrt thing, since the exact distance isn't important there is really no reason to sqrt it.

    The List stays, though. It shouldn't take up that much memory and should provide a substantial speed increase. BTW, why would that be more accurate? should be the same, I would imagine

    Thanks for the suggestions, keep them comming

  13. #63
    Join Date
    Mar 2007
    Posts
    107
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    the accuracy thing was just this
    cout<<sqrt((double)1000000)<<endl;
    cout<<sqrt((double)1000001)<<endl;
    they would be the same, what i said about the list was to make it of ints (or unsigned ints), really unneccessary to use doubles right?

  14. #64
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by sherlockmeister View Post
    the accuracy thing was just this
    cout<<sqrt((double)1000000)<<endl;
    cout<<sqrt((double)1000001)<<endl;
    they would be the same, what i said about the list was to make it of ints (or unsigned ints), really unneccessary to use doubles right?
    ahh, I see. Ok, yep, I agree completely the doubles were not needed in that situation.

  15. #65
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Will we have to learn c++ to script this or will you stick with scar.

  16. #66
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Mylesmadness View Post
    Will we have to learn c++ to script this or will you stick with scar.
    You will need to learn C++. You won't be able to use the scar interface either (So it might not be as intuitive as some may like). You could potentially use pascal with the compiled dll if you really wanted to.

  17. #67
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by boberman View Post
    Dang it, I knew there would be some spelling errors in there, . As for the greater lesser thing, I would disagree with your grammatical logic.

    If I ask you which is greater 1 or 2, of course you would respond 2. If I ask you which is greatest 1 or 2, of course you would respond 2. Both are perfectly correct grammatically. To return a bool would be confusing, IMO (Why would you make such a short function for that anyways?). Greatest implies the biggest of a set while greater implies the bigger of a pair, but not necessarily the biggest in a set. if I did a greatest function I would probably pass it an array and then return the biggest number in the array.
    Hmm, yes, I see your point.

    Got it to compile, pretty happy
    Interested in C# and Electrical Engineering? This might interest you.

  18. #68
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    I fail at getting it to compile - no zlib (just commented out the include as I'm too lazy to download it) then a GetColor and DeleteObject error XD
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  19. #69
    Join Date
    Aug 2007
    Location
    Hawaii
    Posts
    3,880
    Mentioned
    7 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by boberman View Post
    You will need to learn C++. You won't be able to use the scar interface either (So it might not be as intuitive as some may like). You could potentially use pascal with the compiled dll if you really wanted to.
    Its pretty good for the community to. What more do you want from a community with more than half of its people knowing c++ and scar . Good luck on the project. As for me, I dont know any C++, but will try to learn it after school dies.
    Faith is an oasis in the heart which will never be reached by the caravan of thinking.

  20. #70
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    I fail at getting it to compile - no zlib (just commented out the include as I'm too lazy to download it) then a GetColor and DeleteObject error XD
    What are you using to compile it? and what is the error exactly? While I am using Dev-C++ I would like this to be a seamless experience for compiling if you use another building environment.

  21. #71
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Using the latest version of CodeBlocks with MinGW pre-installed on it (the binary bundle) with rev 17. I'll quickly get the latest and try to compile again and get the exact error.
    Edit: Installed zLib just to make sure it wasn't that but still get the 2 errors:
    .objs\ColorFind.o:ColorFind.cpp: (.text+0xcb)||undefined reference to `_DeleteObject@4'|
    .objs\ColorFind.o:ColorFind.cpp: (.text+0x11e)||undefined reference to `_GetPixel@12'|
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  22. #72
    Join Date
    Dec 2007
    Location
    Somewhere in Idaho
    Posts
    480
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You need to point your linker to the libgdi32.a file (or something similar) to compile.

  23. #73
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Hmm if using MinGW, it should compile. Default compiler for Dev-C++ is MinGW


  24. #74
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Adding the linker fixed it
    Now I just need to continue learning C++ and try to contribute before I have no idea what's going on
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  25. #75
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    You can't do scanlines in C++, use GetDIBits.


    Well, anyway, if the only reason for FindColorSpiral would be to get a point closest to the given, just find an array of colors and search through them and compare distances. It would be efficient until you find a way to search in a spiral -- I saw it somewhere, I can't remember... Maybe in the depths of Cruel's VB section.
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

Page 3 of 7 FirstFirst 12345 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 15
    Last Post: 09-22-2008, 12:32 PM
  2. SCAR Divi 3.01 DONT associate .scar files!!!
    By chimpy in forum News and General
    Replies: 1
    Last Post: 04-21-2007, 08:49 PM
  3. Replies: 28
    Last Post: 06-22-2006, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •