diff --git a/config/example_config.json b/config/example_config.json index af5ac16..4c7c0cd 100644 --- a/config/example_config.json +++ b/config/example_config.json @@ -25,7 +25,7 @@ "models": { "models_dir": "data/models", "target_model_vertices": [-1], - "model_visibilities": [1], + "model_visibilities": [0], "model_opacities": [0.5, 1.0, 1.0], "model_representations": ["w", "s", "s"], "reference_to_model": "data/reference_to_model.txt", diff --git a/config/pointer_markers.json b/config/pointer_markers.json new file mode 100644 index 0000000..2d68a26 --- /dev/null +++ b/config/pointer_markers.json @@ -0,0 +1,30 @@ +{ + "camera": { + "source": 0, + "window size": [640, 480], + "calibration directory": "data/calibration/matts_mbp_640_x_480" + }, + "tracker": { + "type" : "sksaruco", + "source" : 0, + "calibration directory": "data/calibration/matts_mbp_640_x_480", + + "rigid bodies" : [ + { + "name" : "modelreference", + "filename" : "data/reference.txt", + "aruco dictionary" : "DICT_ARUCO_ORIGINAL" + }, + { + "name" : "pointerref", + "filename" : "data/pointer.txt", + "aruco dictionary" : "DICT_ARUCO_ORIGINAL" + } + ] + }, + + "interaction": { + "keyboard": true + }, + "out path" : "pointer_positions", +} diff --git a/config/reference_with_model.json b/config/reference_with_model.json index b76c081..d239311 100644 --- a/config/reference_with_model.json +++ b/config/reference_with_model.json @@ -2,14 +2,18 @@ "camera": { "source": 0, "window size": [640, 480], - "calibration directory": "data/calibration/matts_mbp_640_x_480" + "calibration directory": "data/calibration/matts_mbp_640_x_480", + "roi": [0, 0, 640, 480] + }, "tracker": { "type" : "sksaruco", + "source" : 0, + "calibration directory": "data/calibration/matts_mbp_640_x_480", "rigid bodies" : [ { "name" : "modelreference", - "filename" : "data/reference_for_small_liver.txt", + "filename" : "data/reference.txt", "aruco dictionary" : "DICT_ARUCO_ORIGINAL" } ] diff --git a/doc/02_0_Build_Your_Own_Systems.rst b/doc/02_0_Build_Your_Own_Systems.rst index b1c8fce..5a59725 100644 --- a/doc/02_0_Build_Your_Own_Systems.rst +++ b/doc/02_0_Build_Your_Own_Systems.rst @@ -35,6 +35,12 @@ You may need to add if you don't have administrative permissions. +You may also need to install `visioneer` + +:: + + pip install versioneer + **Another method to get BARD and all its dependant packages is the following** :: diff --git a/doc/02_1_Calibrate_Your_Camera.rst b/doc/02_1_Calibrate_Your_Camera.rst index 0d2354b..667c3c0 100644 --- a/doc/02_1_Calibrate_Your_Camera.rst +++ b/doc/02_1_Calibrate_Your_Camera.rst @@ -55,7 +55,7 @@ Use the '-o' option to specify a directory to save to, the For example: :: - python bardVideoCalibration.py -c config/video_calib_chessboard.json -s tests/output -p myresults + python bardVideoCalibration.py -c config/video_calib_chessboard.json -s 0 -o tests/output -p myresults #usage: bardVideoCalibration.py [-h] -c CONFIG [-s SOURCE] [-o OUTPUT] [-p PREFIX] [-ni] [-v] Then, each time the program recalibrates, the results will be saved to the 'tests/output' folder, with the filename prefix 'myresults'. diff --git a/doc/02_2_Tracking_With_AuRcoTags.rst b/doc/02_2_Tracking_With_AuRcoTags.rst index dd30c63..9bea412 100644 --- a/doc/02_2_Tracking_With_AuRcoTags.rst +++ b/doc/02_2_Tracking_With_AuRcoTags.rst @@ -18,7 +18,7 @@ OpenCV. python sksurgerybard.py --config config/example_config.json -When you place the reference marker (data/reference.pdf) in front of the webcam you should +When you place the reference marker found in (data/resources.pdf) in front of the webcam you should see the tag pattern overlaid with spherical markers. Check that the webcam width and height specified in the configuration file are the same as the images you performed calibration on. diff --git a/doc/02_3_Make_Your_Own_Pointer.rst b/doc/02_3_Make_Your_Own_Pointer.rst index c914e4c..d823a33 100644 --- a/doc/02_3_Make_Your_Own_Pointer.rst +++ b/doc/02_3_Make_Your_Own_Pointer.rst @@ -20,9 +20,7 @@ pelvis phantom. :: ls data/PelvisPhantom - CT_Fiduicial_Markers.txt - FullPelvis.vtk - PhantomCroppedJuly08.gipl.gz + >> CT_Fiduicial_Markers.txt FullPelvis.vtk PhantomCroppedJuly08.gipl.gz For now, have a look in the file "CT_Fiduicial_Markers.txt". This is an ordered list of the positions of 4 fiducial markers that we @@ -45,17 +43,25 @@ BARD is tracking the markers, so we know where they are, however we're going to tip of the pointer to locate the fiducial markers. We find the tip of the pointer using a "pivot calibration". The tip of the pointer is held stationary whilst the markers are pivoted around the tip. Pressing the "d" key whilst BARD is running will write -the pointer tracking matrix to the directory pointer_positions/bard_pointer_matrices. Do this around 100 -times whilst pivoting the pointer. Whilst doing this it is important that you do not +the pointer tracking matrix to the directory specified in the config file pointer_markers.json, under the parameter "out path" and then inside the directory bard_pointer_matrices, so for example if the full path is specified to be pointer_positions, the pointer positions will go under the folder pointer_positions/bard_pointer_matrices. +Obtain around 100 pointer positions by pressing the key "d" whilst pivoting the pointer. Whilst doing this, it is important that you do not move either the pointer tip or the tracking system (webcam). When you have a directory of pointer matrices you can run this; :: - python bardPivotCalibration.py --help python bardPivotCalibration.py --input pointer_positions/bard_pointer_matrices -The output of this should be list of 7 numbers. The first three are the x, y and z coordinates of the + +The output of this should be list of 7 numbers, something like this: + +:: + + Pointer Offset = [[-100.19828771 7.16207486 4.48010691]] + Pivot Location = [[-47.31630508 93.11369119 293.46139526]] + Residual Error = 8.382949342574744 + +The first three are the x, y and z coordinates of the pointer tip relative to the tracking markers and should be copied into a file named pointer_tip.txt. The next three numbers are the x,y, and z coordinates of the pointer pivot point relative to the webcam. These can be ignored for now. @@ -67,7 +73,7 @@ less pointer poses. Now edit config/pointer_markers.json to include the the pointer_tag_to_tip transform, within the pointerData entry: :: - "pointerData": { + "pointer": { "pointer_tag_file": "data/pointer.txt", "pointer_tag_to_tip": "data/pointer_tip.txt" }, diff --git a/doc/02_4_Register_And_Ovelay.rst b/doc/02_4_Register_And_Ovelay.rst index 0852bbf..0166153 100644 --- a/doc/02_4_Register_And_Ovelay.rst +++ b/doc/02_4_Register_And_Ovelay.rst @@ -6,12 +6,23 @@ Register and Overlay Model ============================= -Create a plain text-file containing the coordinates of the prostate phantom fiducials, in the same order and format as data/PelvisPhantom/CT_Fiduicial_Markers.txt. These markers have been labeled on the phantom. You must measure the points using the tracked pointer, in the same order. You should end up with a file, of the same format as CT.txt, containing the corresponding world coordinates, lets call it world.txt. +Create a plain text-file containing the coordinates of the prostate phantom fiducials, in the same order and format as data/PelvisPhantom/CT_Fiduicial_Markers.txt. + +You can do this by running + +:: + + python sksurgerybard.py --config config/pointer_markers.json + +These markers have been labeled on the phantom. You must measure the points using the tracked pointer, in the same order. To do this, you can place the pointer tip at each fiducial and press "d" to record the position. + +This should output the files into whatever output file you specified. These points can now be copied and pasted into the world.txt file +You should end up with a file, of the same format as CT_Fiduicial_Markers.txt, containing the corresponding world coordinates, lets call it world.txt. Compute the registration of CT points in CT_Fiduicial_Markers.txt to your world points, run this; :: - python bardProcrustes.py -f world.txt -m data/PelvisPhantom/CT_Fiduicial_Markers.txt + python bardProcrustes.py -f data/PelvisPhantom/world.txt -m data/PelvisPhantom/CT_Fiduicial_Markers.txt So here -f stands for "fixed" points, also called "target" points in the literature, and -m stands for "moving" points, also called "source" points in the literature. This will output a rotation, a translation, and Fiducial Registration Error.