Closed thompson318 closed 4 years ago
In GitLab by @MattClarkson on Mar 21, 2019, 13:48
changed due date to March 29, 2019
In GitLab by @MattClarkson on Mar 21, 2019, 14:20
changed due date to March 28, 2019
In GitLab by @MattClarkson on Mar 21, 2019, 14:20
changed due date to March 27, 2019
In GitLab by @MianAhmad on Mar 22, 2019, 13:43
marked the task See this example in C++, here as completed
In GitLab by @MianAhmad on Mar 22, 2019, 13:45
@MattClarkson
Referring step 2:
Can I make a new project based on python template? In which top level folder I make bard_camera_calibration.py
?
In GitLab by @MianAhmad on Mar 22, 2019, 13:47
Okay, I guess you mean SNAPPY/scikit-surgerybard
In GitLab by @MattClarkson on Mar 22, 2019, 13:55
yes
In GitLab by @MianAhmad on Mar 22, 2019, 13:58
marked the task Create command line app bard_camera_calibration.py in top level folder as completed
In GitLab by @MianAhmad on Mar 22, 2019, 14:02
marked the task Create sksurgerybard/ui/bard_camera_calibration_command_line.py as completed
In GitLab by @MianAhmad on Mar 22, 2019, 14:03
marked the task Create sksurgerybard/ui/bard_camera_calibration_command_app.py as completed
In GitLab by @MianAhmad on Mar 22, 2019, 14:09
marked the task Use existing app as examples on how to run a command line app, i.e. see code in sksurgerybard commmand line app. as completed
In GitLab by @MianAhmad on Mar 22, 2019, 14:17
@MattClarkson : Add correct line to setup.py step
Do you mean to add any packages used in bard_camera_calibration_command_app.py
to the following section in setup.py?
install_requires=[
'six>=1.10',
'numpy>=1.11',
],
In GitLab by @MattClarkson on Mar 22, 2019, 14:29
No. For example, see these: https://weisslab.cs.ucl.ac.uk/WEISS/SoftwareRepositories/SNAPPY/scikit-surgeryutils/blob/master/setup.py#L62
In setup.py, when you pip install the package from PyPi, these lines shown in the link above cause a bash script to be generated that will make a proper shell command that runs python, and launches the right function. i.e. a bash script that can be run like any other command line app, without saying python -m script.py
In GitLab by @MianAhmad on Mar 22, 2019, 15:43
marked the task Add correct line to setup.py as completed
In GitLab by @MianAhmad on Mar 25, 2019, 15:25
Any idea why I am getting the error Unable to import 'cv2' (import-error)
https://weisslab.cs.ucl.ac.uk/MianAhmad/scikit-surgerybard/-/jobs/12270
In GitLab by @MattClarkson on Mar 25, 2019, 15:37
its not in your requirements.txt. Looks like you are developing with locally installed modules, rather than using ones installed by tox.
In GitLab by @MianAhmad on Mar 25, 2019, 15:41
I am using tox in virtual-environment and I added opencv-python
in requirements-dev.txt. I also added opencv-python
in requirements.txt but same result.
In GitLab by @StephenThompson on Mar 25, 2019, 15:56
You need to have cv2 listed in the extension-pkg-whitelist of tests/pylintrc, I think this is necessary for any binary modules. Also try using opencv-contrib-python instead of opencv-python.
extension-pkg-whitelist=numpy,cv2
In GitLab by @MianAhmad on Mar 25, 2019, 16:03
I added numpy,cv2
in tox.ini and tested locally but still the same.
I am moving ahead and will deal with it later :)
[testenv]
deps=-rrequirements-dev.txt
whitelist_externals=coverage,pip,numpy,cv2
# See .coveragerc for list of omitted files
commands = coverage erase
coverage run -a --source ./sksurgerybard -m pytest -v -s ./tests/
coverage report -m
In GitLab by @MianAhmad on Mar 25, 2019, 16:06
here is my forked repo https://weisslab.cs.ucl.ac.uk/MianAhmad/scikit-surgerybard, if interested to clone and test locally.
Branch is 1-command-line-app-to-do-callibration
In GitLab by @MattClarkson on Mar 25, 2019, 16:27
I just pulled that branch. Its not in requirements.txt.
Also, are you saying it doesn't work on the CI server, or on your local environment. Your original comment was the CI server.
In GitLab by @MianAhmad on Mar 25, 2019, 19:13
@MattClarkson
STEP 1: Unable to import 'cv2' (import-error)
Its not working both locally and on CI server.
On local, it didnt work.
virtualenv env1
source env1/bin/activate
cd sikit-surgerybard
tox
I thought may be my settings are not good so I did the commit on gitlab server but same result.
STEP 2: adding the package to requirements.txt
I added the package to requirements.txt and tested locally but same result.
I didnt commit the changes to test it on the CI server.
In GitLab by @MattClarkson on Mar 25, 2019, 19:33
sometimes when I update requirements.txt, I need a completely new .tox folder to get fully up to date dependencies.
Or, it may be the case that the version you are asking for just doesn't exist for python27.
In GitLab by @MianAhmad on Mar 26, 2019, 07:38
That sounds reasonable but I guess not the case. It is coming up in both pythons 2.7 and 3.6.
Mians-MBP:~ mianasbatahmad$ python2
Python 2.7.16 (default, Mar 4 2019, 09:01:38)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.0.0'
>>> quit()
Mians-MBP:~ mianasbatahmad$ python3
Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:10:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.0.0'
>>>
There is a known issue with cv2 in virtualenv and even more when using in tox.https://stackoverflow.com/questions/29115126/importerror-no-module-named-cv2
In GitLab by @MattClarkson on Mar 26, 2019, 08:59
have you got both opencv-python and opencv-contrib-python (or whatever they are called?). You must only have opencv-contrib-python.
In GitLab by @MianAhmad on Mar 26, 2019, 09:43
I have both installed. :(
In GitLab by @MianAhmad on Mar 26, 2019, 11:12
@MattClarkson @StephenThompson You guys are spot-on. Apologies for my laptop error. I should have committed the changes to CI instead of testing locally only. The settings on my laptops are all messed up for different tasks so its not a good test machine.
In GitLab by @MianAhmad on Mar 26, 2019, 13:48
@MattClarkson I got the camera calibration code from opencv website.
I checked it and it works fine.
It is a bit better as it reads all the pictures from a folder and performs the calibration. I test it locally and it works fine.
Is it alright if I use some code from here?
In GitLab by @MattClarkson on Mar 26, 2019, 13:57
stick to standard code where possible, as its meant to be a teaching exercise for students. So, sounds fine to me.
In GitLab by @MianAhmad on Mar 26, 2019, 17:27
Spent some time on the following problem
************* Module sksurgerybard.ui.bard_camera_calibration_command_app
sksurgerybard/ui/bard_camera_calibration_command_app.py:84:16: E1101: Module 'cv2' has no 'TERM_CRITERIA_EPS' member (no-member)
sksurgerybard/ui/bard_camera_calibration_command_app.py:84:40: E1101: Module 'cv2' has no 'TERM_CRITERIA_MAX_ITER' member (no-member)
sksurgerybard/ui/bard_camera_calibration_command_app.py:102:14: E1101: Module 'cv2' has no 'imread' member (no-member)
sksurgerybard/ui/bard_camera_calibration_command_app.py:104:15: E1101: Module 'cv2' has no 'cvtColor' member (no-member)
sksurgerybard/ui/bard_camera_calibration_command_app.py:104:33: E1101: Module 'cv2' has no 'COLOR_BGR2GRAY' member (no-member)
sksurgerybard/ui/bard_camera_calibration_command_app.py:107:23: E1101: Module 'cv2' has no 'findChessboardCorners' member (no-member)
sksurgerybard/ui/bard_camera_calibration_command_app.py:113:23: E1101: Module 'cv2' has no 'cornerSubPix' member (no-member)
sksurgerybard/ui/bard_camera_calibration_command_app.py:126:35: E1101: Module 'cv2' has no 'calibrateCamera' member (no-member)
I figure out that to fix it I have to add the following line to the lint in tox.ini
--extension-pkg-whitelist=cv2
Reference https://github.com/Microsoft/vscode-python/issues/1993
In GitLab by @MianAhmad on Mar 27, 2019, 15:16
@MattClarkson
Its much clear after explaining the hierarchy of
sksurgerybard.py --> sksurgerybard/ui/bard_camera_calibration_command_line.py --> sksurgerybard/ui/bard_camera_calibration_command_app.py
In GitLab by @MianAhmad on Mar 27, 2019, 16:27
One more issue,
I cloned the repo and ideally it should have worked when I issue the command
python sksurgerybard.py -i tests/data/Calibration/ -o calibrationData -x 14 -y 10
However, it is not able to read the files. I checked online and the glob.glob() function is a bit shady. I also tested relative and absolute path for the pngs but didnt work.
If glob.glob is not working particularly on mac than we might change it with another method or reading names from text files
In GitLab by @MianAhmad on Mar 27, 2019, 18:44
The glob.glob work. E.g. if you download the attached file and unzip it.
Running it from terminal using the following command is working.
python test.py -i Calibration/
But when added to bard project and run through the chain then it is failing.
May be there is some permission issue on Mac or the path is not taken right by the argument.
Good luck with it :)
tmp.zip
In GitLab by @MianAhmad on Apr 25, 2019, 11:36
The above issue is now resolved. The application calculate the results correctly.
The below image shows the command with arguments and the calculated response.
@MattClarkson Please accept the merge request if you are happy with the input and output.
In GitLab by @MianAhmad on Apr 26, 2019, 11:23
marked the task Add correct line to setup.py as incomplete
In GitLab by @MianAhmad on Apr 26, 2019, 11:24
marked the task Convert above mentioned C++ to Python, putting most code in bard_camera_calibration_command_app.py as completed
In GitLab by @MianAhmad on Apr 29, 2019, 11:34
marked the task Add correct line to setup.py as completed
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit 93ed0efcd3270b29737e3d97bf02d18275cd15f7
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit 49e6bc86dc373a06ccc9d476129afdd3ab23c64e
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit b30887f53beb6d070e864ee5f104e1327f09d6ab
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit 7535ba00750bdde7562acf2cf77b86a8ba43906c
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit afd0a82eb4ac11578e6279256de9dc3160504de2
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit f7272f53d773b013788feaf87f0634b521a4630f
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit 03c11cd6eb3a634ba2d12e5cc959822395efd70f
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit 8d88d9f4ff0bd7c2352de5257a02ee6df12582ee
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit 51a1552480fc0f1e6b40a801663371102ba094f3
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit f61983ebd6915284bc1856a5335de2c3fb44e25e
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit d7e0aa0e113707483a66b1f1465d5942f4e368f8
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit 8b54ec660d1fd160e80fd7f2a66ad9d8faa21d78
In GitLab by @MattClarkson on Apr 30, 2019, 14:56
mentioned in commit 4e21515bd85b8e71713869673c2925ff696026c8
In GitLab by @MattClarkson on Mar 21, 2019, 13:48
Write simple demo app to do video camera calibration
Hopefully, now you are up to speed, about 1 or 2 days work.
@StephenThompson is familiar with all this, so can provide guidance.