dwalton76 / rubiks-cube-tracker

Given an image of a rubiks cube, find the RGB value for each square.
MIT License
130 stars 37 forks source link

Raspberry pi camera #2

Closed Steven438 closed 5 years ago

Steven438 commented 5 years ago

Hi, i want to ask you if it's s possible to use raspberry pi camera instead a webcam. Sorry for making this an issue and hope you will reply to this. Thanks!

dwalton76 commented 5 years ago

I haven't tried it but I can't think of any reason for it to not work. Give it a try and let me know how it goes.

Steven438 commented 5 years ago

I tried with creating a directory where i captured all sides of a 4x4x4 and write in the terminal "rubiks-cube-tracker.py --directory /home/pi/cubescan". The program analysed the files but very slow and did not give me a solution, just a lot of numbers. The reason that i use raspberry pi camera is the fact that my web camera is very old and doesn't adapt to the light correctly. Any suggestions?

dwalton76 commented 5 years ago

Speed, it is probably going to be slow on a raspberry pi :( Analyzing the six images takes some CPU cycles, I'm sure it will be much faster on a laptop or desktop. How long did it take to run on a pi?

You should see a solution printed when using the --webcam option, you have to install the following first though:

Steven438 commented 5 years ago

Yeah i know i installed all of that, but when I put a webcam and use --webcam 0 it works very fast and well, but my webcam it's very old and doesn't adapt to light correctly. So I read in the ReadMe that I can create a directory where I can put the images of the cube with the name "rubiks-side-B.png", .... . So I made that, capturing all 6 pictures with raspberry pi camera and move the photos in that folder and then write in the LX terminal "rubiks-cube-tracker.py --directory/home/pi/cubescan. The program started analyzing the files but very slow, one image at 20 seconds, and when it finished, give me a lot of numbers for example "[126], [174], [286]... I know that webcam is accessible via dev/video0, and I want to use the raspberry pi camera instead of webcam but I don't know. The webcam doesn't recognize correctly the colors because of light, and I need to try several times to work...

dwalton76 commented 5 years ago

Ah I see what you mean. I can tweak it to print the solution in non webcam mode but in the meantime you can cut-n-paste that list of numbers and feed them to the rubiks-color-resolver which will give you the state of the cube in a big string of ULFRBD characters. Then feed that cube state to the solver and it will give you the solution.

dwalton76 commented 5 years ago

I have a Pi3 I can try this on and see how long it takes. What model pi are you using?

Steven438 commented 5 years ago

I have the pi3 B+

Steven438 commented 5 years ago

And I have another problem, I cant find the color resolver or cube tracker file on my pi, just the NxNxN solver and I've searched a lot.

dwalton76 commented 5 years ago

Start with https://github.com/dwalton76/rubiks-color-resolver if you follow the README there and do which rubiks-color-resolver.py does it find it?

For https://github.com/dwalton76/rubiks-cube-NxNxN-solver the README also has install instructions