Dinones / Nintendo-Switch-Pokemon-Shiny-Hunter

Search for shiny pokémon on your Nintendo Switch while sleeping!
Other
83 stars 4 forks source link

RaspBerry PI4 B Model - 4/5 FPS MAX (32GB Storage / 4GB RAM) #38

Closed MCPika closed 2 months ago

MCPika commented 2 months ago

Hi Dino,

I just wanted to pop the question as I've tried to install your program on my Raspberry PI4 with integrated Bluetooth card with Ubuntu 20.04.5 server version on it. (4GB RAM)

It works but the FPS turn around 4-5 when launching the program and I think it hurts your program more than anything. Any tips on how to up the performance on this one or is there none at all?

Thanks in advance for any possible answers !

chaosfreakx commented 2 months ago

Hi Dino,

I just wanted to pop the question as I've tried to install your program on my Raspberry PI4 with integrated Bluetooth card with Ubuntu 20.04.5 server version on it. (4GB RAM)

It works but the FPS turn around 4-5 when launching the program and I think it hurts your program more than anything. Any tips on how to up the performance on this one or is there none at all?

Thanks in advance for any possible answers !

Are you able to help me please install on RP4 8g i have it working on VM but cant get it to work on my RP4

MCPika commented 2 months ago

Hey ! Sure no worries I know for a fact it could be a headache ! Ive just tuned in on RPI4 and its been 3days straight to figure out how everything worked but in the end I got it working so hit me up on discord if you want we'll try to see what can be done about it ! (Discord Username : pika5326)

David34920 commented 2 months ago

I have performance issues too. I've just make a PR: https://github.com/Dinones/Nintendo-Switch-Pokemon-Shiny-Hunter/pull/39

Dinones commented 2 months ago

Hi! I tested the program a while ago on a Raspberry Pi 4 with 8GB. In my case, the issue turned out to be related to the capture speed of the capture card. During the verification process, what FPS do you get when you run the testing user interface and select the option Open GUI using capture card? For me, it was around 4-5 FPS.

David34920 commented 2 months ago

In my case (not Raspberry) I'm between 15 and 20 FPS with one CPU at 100%.

MCPika commented 2 months ago

-- RaspBerry PI4 - 4GB RAM / 32GB SD Memory Card - UBUNTU 20.04.5 server installed -- (while on VM im at 30FPS constantly) When using the testing bench with the option "OpenGUI" I'm between 19-21 FPS im posting an image right about now - image

When launching the game through "Shiny Hunter" this is the screen I get - 10-11FPS when pairing up image 4-5FPS when in game image

Dinones commented 2 months ago

In my case (not Raspberry) I'm between 15 and 20 FPS with one CPU at 100%.

What resources are you allocating to the VM? For reference, I have a mini computer, "NiPoGi AK2PLUS Mini PC," which runs at 10-20 FPS, and it's not a problem—I've already found some shinies on it.

It works but the FPS turn around 4-5 when launching the program and I think it hurts your program more than anything.

What I'm worried about is the Raspberry Pi running at 5 FPS. I'll need to check which parts of the code require more resources, but I suspect it might be NXBT. Could you please test if the Switch controller verification gives you the same FPS?

On the other hand, when you run the testing GUI with the capture card image and walk around the overworld in the Pokémon game, do the FPS also drop to 5?

MCPika commented 2 months ago

What I'm worried about is the Raspberry Pi running at 5 FPS. I'll need to check which parts of the code require more resources, but I suspect it might be NXBT. Could you please test if the Switch controller verification gives you the same FPS?

On the other hand, when you run the testing GUI with the capture card image and walk around the overworld in the Pokémon game, do the FPS also drop to 5?

Well when testing Switch-Controller.py im between 13-20FPS image image

Dinones commented 2 months ago

On the other hand, when you run the testing GUI with the capture card image and walk around the overworld in the Pokémon game, do the FPS also drop to 5?

And what happens when you try this?

MCPika commented 2 months ago

On the other hand, when you run the testing GUI with the capture card image and walk around the overworld in the Pokémon game, do the FPS also drop to 5?

Im at a constant 15-17 FPS image

But when the game launches im at 20-25FPS

Dinones commented 2 months ago

I'll have to take a closer look at this, then. Another question: does the issue get resolved if you use David's pull request?

MCPika commented 2 months ago

Another question: does the issue get resolved if you use David's pull request?

I did not try that, I haven't had the time lean into it. Where can I find his pull?

David34920 commented 2 months ago

On a terminal, go to the app folder, then enter: git checkout disable-recording Then edit Constant.py to set value ENABLE_VIDEO_RECORDING to False

To come back to the original version set back the value to True, then enter git checkout master

FYI: In my case, the CPU is still at 100% but I have a better FPS and less crash (from nxbt or other)

David34920 commented 2 months ago

FYI @Dinones I've profiled the app. I've used cProfile to do it: https://github.com/David34920/Nintendo-Switch-Pokemon-Shiny-Hunter/tree/profile-threads Here are the results: output Video recording was disabled.

In my case VideoCapture.read is taking 100% of the time

David34920 commented 2 months ago

I made a try on Game_Capture.py I see that after reading the image from the VideoCapture, the image is resized to 720x405 so I captured the image directly to that size:

        self.video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, 720)
        self.video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 405)

The CPU usage is now between 40 and 50% instead of blocked at 100% The app seems to work still, but

Details that can be easily fixed if you think that change is valid to optimize the CPU usage

Dinones commented 2 months ago

Hi @David34920! I've seen you've been really focused on the project, addressing issues and submitting pull requests. I really appreciate your help! I'd like to speak with you, could you please add me on Discord?

David34920 commented 2 months ago

@MCPika after testing, you can edit Constants.py to reduce the capture resolution with this value:

ORIGINAL_FRAME_SIZE = (1280, 720)

On my side, I'm now running at 25/30 FPS (still with video recording disabled)

MCPika commented 2 months ago

@MCPika after testing, you can edit Constants.py to reduce the capture resolution with this value:

I'm going to try that just now I'll tell you what I have as an output ! Thanks for the input !

MCPika commented 2 months ago

@David34920 @Dinones So when using David pull request :

So this is entirely better 👍 But too bad Video_Recording seems to halve the frame rates on RaspBerry. How does that work I would think that it would at least ask for more RAM (which it has) to deploy better usage of the process?

David34920 commented 2 months ago

I don't know the details, this is maybe due to the fact that the API is not using the hardware to save the video. It will require some investigation.

In any case, this is great that you reach a descent FPS with that tuning.

Dinones commented 2 months ago

Thank you, @David34920, for your help in resolving this issue! Wish you lots of shinies, @MCPika! Good luck!