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

Isn't working after 2019 update #4

Closed Steven438 closed 5 years ago

Steven438 commented 5 years ago

Hello, I just updated the version of this project (last update was in april 2018) and do this command: rubiks-cube-tracker.py --directory /home/pi/cubescan But give me this error:

2019-04-25 09:10:20,990 init.py INFO: Analyze /home/pi/cubescan/rubiks-side-U.png Traceback (most recent call last): File "/usr/local/bin/rubiks-cube-tracker.py", line 74, in rimg.analyze_file(filename, cube_size) File "/usr/local/lib/python2.7/dist-packages/rubikscubetracker/init.py", line 1555, in analyze_file return self.analyze(webcam=False, cube_size=cube_size) File "/usr/local/lib/python2.7/dist-packages/rubikscubetracker/init.py", line 1407, in analyze self.get_black_border_width() File "/usr/local/lib/python2.7/dist-packages/rubikscubetracker/init.py", line 1050, in get_black_border_width "black_border_width %s, median_square_width %s" % (self.black_border_width, self.median_square_width) AssertionError: black_border_width 60, median_square_width 21 Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1545, in call return self.func(*args) File "window.py", line 42, in first cube3.analizer() File "/home/pi/cube3.py", line 724, in analizer output1 = check_output(cmd1, shell=True) File "/usr/lib/python2.7/subprocess.py", line 219, in check_output raise CalledProcessError(retcode, cmd, output=output) CalledProcessError: Command 'rubiks-cube-tracker.py --directory /home/pi/cubescan' returned non-zero exit status 1

I tested the same image in the previous update and worked perfect. I need to do this comand instead of -webcam because this is the way i implemented it in my software (I work to a robot that can solve the 3x3x3 cube). Here is my image:

rubiks-side-U

If you can help me with that or maybe just give me the previous version and how to intall it because i'm new to linux (use the raspberry pi3 now - also for the robot project).#

THANKS in advance, Steven

Steven438 commented 5 years ago

Now i tested in webcam mode but same error, here is it:

rubiks-cube-tracker.py --webcam 0 Traceback (most recent call last): File "/usr/local/bin/rubiks-cube-tracker.py", line 49, in rvid.analyze_webcam() File "/usr/local/lib/python2.7/dist-packages/rubikscubetracker/init.py", line 1711, in analyze_webcam if self.analyze(webcam=True): File "/usr/local/lib/python2.7/dist-packages/rubikscubetracker/init.py", line 1407, in analyze self.get_black_border_width() File "/usr/local/lib/python2.7/dist-packages/rubikscubetracker/init.py", line 1050, in get_black_border_width "black_border_width %s, median_square_width %s" % (self.black_border_width, self.median_square_width) AssertionError: black_border_width 94, median_square_width 40

I tried to donwload the APRIL 2018 version but i couldnt, i dont know how to install it... Then i copied the init.py file and when i wanted to paste into my file on the raspberry pi seems like i cant edit that file.... So im stuck here and i dont know what to do... If you can help me please.... THANKS

dwalton76 commented 5 years ago

Can you attach all six of the images to the issue here? I should be able to reproduce it with those and figure out what is going on.

Steven438 commented 5 years ago

rubiks-side-B rubiks-side-D rubiks-side-F rubiks-side-L rubiks-side-R rubiks-side-U

Steven438 commented 5 years ago

Some of them are rotated 90 and 180 grades but that is because the mechanism of the robot rotatetes the cube phisically. I tested all this images with the 2018 version and worked perfectlly.

Steven438 commented 5 years ago

Tried multiple times with diffrent images. Still doesn't work. It's been 4 hours since i search on google how to clone a repository from an historical moment. Nothing found to work. I can't understand why don't let me modify the init.py file... Here is the location: /usr/local/lib/python2.7/dist-packages/rubikscubetracker If you have an ideea please write it here. I need the robot to work until 5 may because i have a presentation with it. I'm new to open cv and yours software is the best that i could find. Hope you will reply to this, Steven

dwalton76 commented 5 years ago

I made a change to cranecuber on Feb 12 so that the images of sides U and D would no longer need to be rotated. I think what has happened is you updated to the latest rubikscubetracker code but not the latest cranecuber code. Can you cd to your cranecuber directory and do git pull, then run it again and let me know what you get.

Steven438 commented 5 years ago

The thing is that i didint install cranecuber... I viewed the instructions and adapted for 3 stepper motors, one pi camera and raspberry pi. And the software I wrote myself. I integrated the rubiks-cube-tracker and then color resolver and then the NxNxN solver. I managed to get the output and adapted for the stepper motors. I didn't want to copy your project, I had it as an inspiration source. I got the robot working very well (90 seconds for the 3x3x3 cube including inspection). I presented it to school and they invited me around 5 may. The thing is I saw today that you updated the color tracker and I installed this new version. But is not working, don't know why. I can share all my code with you (2 python scripts, approximate 1400 lines in total). I'm just 16 years old and I started this project in June 2018. If you can fix this version I would be very happy, if not just help me reinstall the old version. THANKS a lot.

dwalton76 commented 5 years ago

That sounds awesome, congrats :) Do you have a blog or something about the project?

ok a few options here to get you going:

Steven438 commented 5 years ago

I plan to make a blog where to describe the project, maybe in the next weeks, but first I work to add support for the 4x4x4, 5x5x5 and 6x6x6 cube. I will share you a link when I finish the blog.

I tried the cd ~/rubikscubetracker command but returns "no such file or directory". Then I made a general search on the raspberry pi and the only one folder that I got was in /usr/local/lib/python2.7/dist-packages Because of that when I run the second command, returns "not a git repository". Maybe the folder has another name. Thank you for the reply!

Steven438 commented 5 years ago

I cloned the repository and I did the commands you told me. Seems like it's installed but when I run "rubiks-cube-tracker.py --filename" command gives me an error. Now I can't run it anymore.

dwalton76 commented 5 years ago

Can you cut-n-paste the error you are hitting

Steven438 commented 5 years ago

rubiks-cube-tracker.py --filename /home/pi/cubescan/rubiks-side-B.png Traceback (most recent call last): File "/usr/local/bin/rubiks-cube-tracker.py", line 4, in import('pkg_resources').run_script('rubikscubetracker==1.0.0', 'rubiks-cube-tracker.py') File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 739, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 1486, in run_script raise ResolutionError("No script named %r" % script_name) pkg_resources.ResolutionError: No script named 'rubiks-cube-tracker.py'

dwalton76 commented 5 years ago

Hmm something is hosed, try this:

sudo rm -rf /usr/local/lib/python2.7/dist-packages/rubikscubetracker
sudo rm /usr/local/bin/rubiks-cube-tracker.py
cd
git clone https://github.com/dwalton76/rubiks-cube-tracker.git
cd rubiks-cube-tracker
git checkout 3fcf92a0a47aa84800d01f66b50e5131799dbc5b
sudo python2 setup.py install
Steven438 commented 5 years ago

it doesn't work, gives me the same error:

~/rubiks-cube-tracker $ rubiks-cube-tracker.py --filename /home/pi/cubescan/rubiks-side-B.png Traceback (most recent call last): File "/usr/local/bin/rubiks-cube-tracker.py", line 4, in import('pkg_resources').run_script('rubikscubetracker==1.0.0', 'rubiks-cube-tracker.py') File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 739, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 1486, in run_script raise ResolutionError("No script named %r" % script_name) pkg_resources.ResolutionError: No script named 'rubiks-cube-tracker.py'

Steven438 commented 5 years ago

Now i removed the file in /usr/local/bin/rubiks-cube-tracker.py but gives me this error: rubiks-cube-tracker.py --filename /home/pi/cubescan/rubiks-side-B.png bash: /usr/local/bin/rubiks-cube-tracker.py: No such file or directory

Steven438 commented 5 years ago

I removed some files and move a folder around, changed the terminal comand to "python rubiks-cube-tracker.py --filename /home/pi/cubescan/rubiks-side-B.png" and seems to work. Tested the robot and solved succesfull the cube in around 90 seconds. Everything works fine now. THANKS a lot for your support. I will give you a link to a blog with this robot when i finish it. THANKS again!!!

dwalton76 commented 5 years ago

awesome glad to hear it :)

Long term I would tweak your robot to photograph all sides so that they do not require image rotation...that way you can pick up all of the recent improvements in rubikscubetracker