Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

PixelGetColor is too slow or I doing something wrong?



  • Please log in to reply
20 replies to this topic
dsewq1LYJ
  • Members
  • 203 posts
  • Last active: May 12 2018 05:04 AM
  • Joined: 16 Jul 2014

TWICE POST........DEEPLY SORRY.....



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

Yes I got two lines of color

0x6392A4

0x6392A4

 

Absolute one color.So..that's no way to make it faster ?

 

OK, the script stopped because it found the color.

You can see that it could detect the color.

 

But, there is something which seems weird, to me.
You only have 2 color values in the log file.
I was expecting tens of colors, maybe hundreds of them.
How did you launch the script exactly at the time the color appeared ?
The color is supposed to appear suddenly and not very long.

 


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


dsewq1LYJ
  • Members
  • 203 posts
  • Last active: May 12 2018 05:04 AM
  • Joined: 16 Jul 2014

OK, the script stopped because it found the color.

You can see that it could detect the color.

 

But, there is something which seems weird, to me.
You only have 2 color values in the log file.
I was expecting tens of colors, maybe hundreds of them.
How did you launch the script exactly at the time the color appeared ?
The color is supposed to appear suddenly and not very long.

I'll try it again.

 

But I guess there's absolute four colors of the point (by my eyes.)

*You actually give me a cool idea.I realized that's a "overlay" on the point.

If I can remove the "overlay" then I thought I can get the pixel directly(faster).( --- if possible)

 

--- I try to make it faster with different language.

... I can not believe AutoHotkey is so much faster than the others

(Idk why. Maybe just Im only good at simple Script.I dont deeply understand about High level programmin')



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013
✓  Best Answer

In the meantime, I changed the script and corrected a small logic error.

The old script printed twice the array.

Now, it prints the color and its number of occurrence.

I intentionally changed the color. I hope the choosen color won't be found.

You'll have to stop the script manually with the Escape key.

SetFormat, IntegerFast, H
global Array1 := []
global Array2 := []
IfExist, % A_ScriptName ".txt"
	FileDelete, % A_ScriptName ".txt"
OnExit, Quit
return

MButton::
i := WaitPixelColor(590, 943, 0x010101)
MsgBox, % "Done ! " i
gosub, Esc
ExitApp

Esc::
for index, color in Array1
	FileAppend, % color " " Array2[index] "`r`n", % A_ScriptName ".txt"
ExitApp

Quit:
ExitApp

WaitPixelColor(_x, _y, _color)
{
	static lOldColor=0
	Loop
	{
		PixelGetColor, lColor, _x, _y
		if (lColor <> lOldColor)
		{
			Array1.Insert(lColor)
			Array2.Insert(1)
			lOldColor := lColor
		}
		else
			Array2[Array2.MaxIndex()]++
		if (lColor = _color)
			return A_Index
	}
	return lCpt
}


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


dsewq1LYJ
  • Members
  • 203 posts
  • Last active: May 12 2018 05:04 AM
  • Joined: 16 Jul 2014

 

In the meantime, I changed the script and corrected a small logic error.

The old script printed twice the array.

Now, it prints the color and its number of occurrence.

I intentionally changed the color. I hope the choosen color won't be found.

You'll have to stop the script manually with the Escape key.

SetFormat, IntegerFast, H
global Array1 := []
global Array2 := []
IfExist, % A_ScriptName ".txt"
	FileDelete, % A_ScriptName ".txt"
OnExit, Quit
return

MButton::
i := WaitPixelColor(590, 943, 0x010101)
MsgBox, % "Done ! " i
gosub, Esc
ExitApp

Esc::
for index, color in Array1
	FileAppend, % color " " Array2[index] "`r`n", % A_ScriptName ".txt"
ExitApp

Quit:
ExitApp

WaitPixelColor(_x, _y, _color)
{
	static lOldColor=0
	Loop
	{
		PixelGetColor, lColor, _x, _y
		if (lColor <> lOldColor)
		{
			Array1.Insert(lColor)
			Array2.Insert(1)
			lOldColor := lColor
		}
		else
			Array2[Array2.MaxIndex()]++
		if (lColor = _color)
			return A_Index
	}
	return lCpt
}

OLDMAN YOU ARE TRULY GOD.

I FIGURE OUT THE 'TRUE 1st COLOR' OF THE 'PIXEL'

THE PIXEL WHAT I AM CAPTUREING IS NOT THE '1ST'

SO I GOT WRONG STUFF.

 

I DEEPLY APPRECIATE IT...YOU HELP ME AAAAA LOOOT



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

Wow, this is a real positive reaction.
Well, a simple thanks would have been far sufficient.
I'm glad I could help you.


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)