Open Royml opened 3 years ago
Hi Royml, I'm unable to reproduce the error on Windows or macOS. Try turning the sailor coordinates into a tuple: cv.circle(app.img, ((sailor_x, sailor_y)), 3, (255, 0, 0), -1). If this doesn't help, try running the bayes.py code downloaded from github. This ran okay for me. Let me know how it goes.
Hi, the tupl(ing) didn't fix it, but I did manage to resolve with int() on the sailor_x and sailor_y.
It could be a python version issue, mine is 3.8.5
Okay. I'm in the process of transferring to a new computer and installing Anaconda with the latest version of Python. I'll revisit this when I have everything up and running in the next week or so. Thanks.
Could you also let me know which version of OpenCV you are using? Thanks.
cv.circle(app.img, (sailor_x.item(0), sailor_y.item(0)), 3, (255, 0, 0), -1) # Returns a standard Python scalar and should fix the problem. Alternatively, using sailor_x[0] and sailor_y[0] should also work.
A better solution would be changing lines 90 & 91 to the following: self.sailor_actual[0] = np.random.choice(self.sa1.shape[1]) self.sailor_actual[1] = np.random.choice(self.sa1.shape[0])
This returns an integer directly so no need to jump through hoops. Thanks to Alexander Valarus for pointing this out.
getting the sailor position to show I could not get the last "else" line cv.circle...to work I had to modify the draw _map method with an extra parameter 'actual_position' which is set to(0,00 when the not wanted and to the position when wanted the draw_map method then includes the "cv. circle.." which is activated when actual_position !=(0,0)
I also had to destroyAlllWindows after the imshow to get the draw_map to work twice
Hmmm. A few questions: -What OS are you using? -Are you launching the program from a terminal/powershell or from your IDE? -Are you running the bayes.py I supplied on github? This has been tested on multiple systems.
I ran your code again, it works fine. I’ll there must have been an erro between the chair and the key board Thanks again
Sent from my iPhone
On Jan 16, 2021, at 1:11 PM, rlvaugh notifications@github.com wrote:
Hmmm. A few questions: -What OS are you using? -Are you launching the program from a terminal/powershell or from your IDE? -Are you running the bayes.py I supplied on github? This has been tested on multiple systems.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
That's good news! It's easy to mistype something going from the book to the keyboard. If you run the supplied code and it works differently, you can compare your code to mine using online comparison tools or by pasting the code into two different Microsoft Word docs and then using the compare feature under the Review tab. This will highlight any changes, making them easy to find.
Thanks for the tip!
On Sat, Jan 16, 2021 at 5:13 PM rlvaugh notifications@github.com wrote:
That's good news! It's easy to mistype something going from the book to the keyboard. If you run the supplied code and it works differently, you can compare your code to mine using online comparison tools or by pasting the code into two different Microsoft Word docs and then using the compare feature under the Review tab. This will highlight any changes, making them easy to find.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rlvaugh/Real_World_Python/issues/1#issuecomment-761709681, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANARLRJDAYBWXPX34CQI3OLS2I2VLANCNFSM4VQ3I2CQ .
I’m still flummoxed by the gensim import Have asked pyCharm for their advice. I had just updated pyCharm when the imports started to have problems -- Regards, Doug Brown
Chapter_1\bayes.py", line 234, in main cv.circle(app.img, (sailor_x, sailor_y), 3, (255, 0, 0), -1) TypeError: only integer scalar arrays can be converted to a scalar index