Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fps? #16

Open
frankandrobot opened this issue Oct 21, 2017 · 4 comments
Open

fps? #16

frankandrobot opened this issue Oct 21, 2017 · 4 comments

Comments

@frankandrobot
Copy link

what kind of fps can I expect on a relatively decent mac?

@vova616
Copy link
Owner

vova616 commented Oct 22, 2017

I'm not sure as this library was not developed to record many frames in a second, more like a frame every now and then

@kesarion
Copy link
Contributor

kesarion commented Oct 23, 2017

This is something for you to test out as it depends on system configuration. I've only ever tested this on Windows, I may get to do it on a mac at some point. On Windows I recall the fastest pixel array retrieval taking around 10ms, that would mean 100fps if you don't count in any image processing at all (i.e. if you only need the pixels).

I thought this was slow though and it was impossible to multithread the retrieval due to the Windows API. I think it's almost guaranteed to work better on mac and linux.

If speed is what you're looking for, you shouldn't use this package directly, rather, take a look at lines 30 to 51 for the darwin implementation and copy what you need.

@frankandrobot
Copy link
Author

100fps is probably good enough. I was thinking of putting this in front of something like the MAME emulator and pipe the images to an AI engine. There's a github repo somewhere that does exactly this but it is specific to MAME and also uses python.

@NietThijmen
Copy link

Might be a little late to the party but for people just wanting to know:

Testing setup:

Laptop: M2 macbook air (16GB of ram if it matters)

Tested in golang: go version go1.21.6 darwin/arm64

Tested in goland IDE

Screenshot duration: 105MS

Interesting discovery:

It appears when doing this in a loop over 100 iterations it appears that the average time to take a screenshot appears to be
21MS. This would make it be a maximum of: 47,619FPS not close to the 100 needed but still a higher number then 9.5FPS.

Code used for testing:

screen.go

package capture

import (
	"github.com/vova616/screenshot"
	"image"
)

func Capture() (image.Image, error) {
	img, err := screenshot.CaptureScreen()
	if err != nil {
		return nil, err
	}

	myImg := image.Image(img)
	return myImg, nil
}

screen_test.go

package capture

import (
	"testing"
	"time"
)

func TestCapture(t *testing.T) {
	beginTime := time.Now()
	_, err := Capture()
	if err != nil {
		t.Error("Capture failed: ", err)
	}

	elapsed := time.Since(beginTime)

	t.Logf("Capture took %s", elapsed)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants