evo-biomech / scAnt

open-source 3D scanning and processing pipeline
MIT License
159 stars 37 forks source link

Slow scanning progress #5

Closed FabianPlum closed 2 years ago

FabianPlum commented 2 years ago

Following up on a comment posted by @sbasnagala in https://github.com/evo-biomech/scAnt/issues/2#issuecomment-1079000749


Hi Fabian, Thanks!! All the stepper motors working right now!! I started scanning and it seems like it is very slow. It's been 12 min into the scan so far and when I check the output folder, there are only 7 images taken every 2 seconds. The progress bar is still 0%, and says "running Scan". I can see the image is not focused in the live view and z-axis is not moving and the gimble arc stopped halfway between 0 and ends top. Any clue what is going on?

Originally posted by @sbasnagala in https://github.com/evo-biomech/scAnt/issues/2#issuecomment-1079000749

FabianPlum commented 2 years ago

Could you post your scan settings here so we can have a look? One image every two seconds is not necessarily unusual, given the time it takes the scanner to move from one position to the next. Are you using the latest version of the scAnt code?

sbasnagala commented 2 years ago

image 1 image 2

sbasnagala commented 2 years ago

Yes I updated the script file.

FabianPlum commented 2 years ago

Did you download the latest version of the entire repository or only one specific file?

It also seems like you are using two 5 mm extension tubes for a relatively large specimen. In this case, one should suffice. Check that the animal is properly in focus, by adjusting the focus on the lens.

sbasnagala commented 2 years ago

image 3

sbasnagala commented 2 years ago

I am not sure if I download all, I will check and update the files again and try again. Thanks

FabianPlum commented 2 years ago

Are you using a USB 3.0 (or later) cable for the camera? If not, that may lead to long transfer times. It also appears, that your image looks not well exposed.

You can try opening the aperture of your lens further and increasing the gain. You should also adjust the red and blue balance ratios, as right now the image appears to have a noticeable blue tint

sbasnagala commented 2 years ago

yes, I am using USB 3.1. I have attached the whole log information below, in case you capture anything I am doing wrong, please let me know. Right now Z-axis stopped at -10000 and not going further, Image is not focused. The scanner is running but nothing happening. The saved images are not in focus. I have attached a screenshot of the settings.

image 4

(base) C:\Users\basnagala.1>cd C:\Users\basnagala.1\Documents\GitHub\scAnt

(base) C:\Users\basnagala.1\Documents\GitHub\scAnt>conda activate scAnt

(scAnt) C:\Users\basnagala.1\Documents\GitHub\scAnt>python scAnt.py Spinnaker library version: 2.5.0.80 Detected Blackfly S BFS-U3-200S6C with Serial ID 21519381 Number of cameras detected: 1

Execute CustomFLIR.initialise_camera and pass the number of the listed camera, in case more than one has been detected!

Acquisition mode set to continuous... CONFIGURING EXPOSURE

Automatic exposure disabled... Shutter time set to 90000 us...

Automatic exposure enabled... Automatic gain enabled... Homing stepper X Home reached for stepper: X QObject::connect: Cannot queue arguments of type 'QList' (Make sure 'QList' is registered using qRegisterMetaType().) QObject::connect: Cannot queue arguments of type 'QList' (Make sure 'QList' is registered using qRegisterMetaType().) QObject::connect: Cannot queue arguments of type 'QList' (Make sure 'QList' is registered using qRegisterMetaType().) Homing stepper Z Home reached for stepper: Z disabling inputs! Started background processing queue... [array([190, 240, 290, 340, 390, 440]), array([ 0, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 480, 520, 560, 600, 640, 680, 720, 760, 800, 840, 880, 920, 960, 1000, 1040, 1080, 1120, 1160, 1200, 1240, 1280, 1320, 1360, 1400, 1440, 1480, 1520, 1560]), array([-20000, -19500, -19000, -18500, -18000, -17500, -17000, -16500, -16000, -15500, -15000, -14500, -14000, -13500, -13000, -12500, -12000, -11500, -11000, -10500, -10000, -9500, -9000, -8500, -8000])] Moving stepper X to position 190 Moving stepper Y to position 0 Displaying progress! Moving stepper Z to position -20000 Displaying progress! Captured Image with width = 5472, height = 3648 Time to write image to device: 9.150751829147339 seconds Displaying progress! Moving stepper Z to position -19500 Captured Image with width = 5472, height = 3648 Time to write image to device: 1.7403461933135986 seconds Moving stepper Z to position -19000 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step20000.tif Displaying progress! Captured Image with width = 5472, height = 3648 Time to write image to device: 1.534893274307251 seconds Moving stepper Z to position -18500 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step19500.tif Displaying progress! Captured Image with width = 5472, height = 3648 Time to write image to device: 1.6525793075561523 seconds Moving stepper Z to position -18000 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step19000.tif Displaying progress! Captured Image with width = 5472, height = 3648 Time to write image to device: 1.5887506008148193 seconds Displaying progress! Moving stepper Z to position -17500 Captured Image with width = 5472, height = 3648 Time to write image to device: 1.6685364246368408 seconds Moving stepper Z to position -17000 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step18500.tif Captured Image with width = 5472, height = 3648 Time to write image to device: 1.6416120529174805 seconds Moving stepper Z to position -16500 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step18000.tif Displaying progress! Displaying progress! Captured Image with width = 5472, height = 3648 Time to write image to device: 1.6047050952911377 seconds Moving stepper Z to position -16000 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step17500.tif Captured Image with width = 5472, height = 3648 Time to write image to device: 1.7582964897155762 seconds Moving stepper Z to position -15500 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step17000.tif Displaying progress! Displaying progress! Captured Image with width = 5472, height = 3648 Time to write image to device: 1.62166166305542 seconds Moving stepper Z to position -15000 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step16500.tif Captured Image with width = 5472, height = 3648 Time to write image to device: 1.6096949577331543 seconds Moving stepper Z to position -14500 Captured Image with width = 5472, height = 3648 Time to write image to device: 1.6017162799835205 seconds Moving stepper Z to position -14000 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step16000.tif Displaying progress! Displaying progress! Displaying progress! Captured Image with width = 5472, height = 3648 Time to write image to device: 1.5777802467346191 seconds Moving stepper Z to position -13500 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step15500.tif Captured Image with width = 5472, height = 3648 Time to write image to device: 1.6455960273742676 seconds Moving stepper Z to position -13000 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step15000.tif Captured Image with width = 5472, height = 3648 Time to write image to device: 1.7612888813018799 seconds Moving stepper Z to position -12500 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step14500.tif Displaying progress! Displaying progress! Displaying progress! Error: Spinnaker: Could not find image to release [-1013] Captured Image with width = 5472, height = 3648 Time to write image to device: 1.665811538696289 seconds Moving stepper Z to position -12000 Captured Image with width = 5472, height = 3648 Time to write image to device: 1.8108513355255127 seconds Moving stepper Z to position -11500 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step14000.tif Captured Image with width = 5472, height = 3648 Time to write image to device: 1.7064359188079834 seconds Moving stepper Z to position -11000 Image saved as C:\Users\basnagala.1\Documents\3D PRINTER\scANT\scAnt images\StinkBug\SB1\SB1\RAW_x_00190_y_00000_step13500.tif SpinnakerException Python 3.7.12: C:\Users\basnagala.1\Anaconda3\envs\scAnt\python.exe Fri Mar 25 15:42:05 2022

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

C:\Users\basnagala.1\Documents\GitHub\scAnt\scAnt.py in checkActiveStackThreads(self=<__main__.scAnt_mainWindow object>) 1220 print("Failed to save:", img[1]) 1221 print(error_save_FLIR_img) 1222 img[0].Release() 1223 # remove entries from queue once done 1224 self.FLIR_image_queue.remove(img) img = [<PySpin.PySpin.ImagePtr; proxy of <Swig Object o... 'Spinnaker::ImagePtr *' at 0x00000258C556FD20> >, r'C:\Users\basnagala.1\Documents\3D PRINTER\scANT...kBug\SB1\SB1\RAW_x_00190_y_00000_step13500.tif'] ].Release undefined

C:\Users\basnagala.1\Anaconda3\envs\scAnt\lib\site-packages\PySpin\PySpin.py in Release(self=<PySpin.PySpin.ImagePtr; proxy of <Swig Object o... 'Spinnaker::ImagePtr ' at 0x00000258C556FD20> >) 36145 def Release(self): 36146 r"""Release(self)""" 36147 return _PySpin._SWIG_ImgPtr_Release(self) 36148 36149 def GetID(self): global _PySpin = <module 'PySpin._PySpin' from 'C:\Users\basnag...te-packages\PySpin\_PySpin.cp37-win_amd64.pyd'> _PySpin._SWIG_ImgPtr_Release = self = <PySpin.PySpin.ImagePtr; proxy of <Swig Object o... 'Spinnaker::ImagePtr ' at 0x00000258C556FD20> > SpinnakerException: Spinnaker: Could not find image to release [-1013] cause = None class = <class '_PySpin.SpinnakerException'> context = None delattr = <method-wrapper 'delattr' of SpinnakerException object> dict = {} dir = doc = 'Exception class for the PySpin module. This clas...these attributes: message, errorcode, fullmessage' eq = <method-wrapper 'eq' of SpinnakerException object> format = ge = <method-wrapper 'ge' of SpinnakerException object> getattribute = <method-wrapper 'getattribute' of SpinnakerException object> gt = <method-wrapper 'gt' of SpinnakerException object> hash = <method-wrapper 'hash' of SpinnakerException object> init = <method-wrapper 'init' of SpinnakerException object> init_subclass = <built-in method init_subclass of type object> le = <method-wrapper 'le' of SpinnakerException object> lt = <method-wrapper 'lt' of SpinnakerException object> module = '_PySpin' ne = <method-wrapper 'ne' of SpinnakerException object> new = reduce = reduce_ex = <built-in method reduce_ex of SpinnakerException object> repr = <method-wrapper 'repr' of SpinnakerException object> setattr = <method-wrapper 'setattr' of SpinnakerException object> setstate = sizeof = str = <method-wrapper 'str' of SpinnakerException object> subclasshook = __suppress_context = False traceback = weakref__ = None args = ('Spinnaker: Could not find image to release [-1013]',) errorcode = -1013 fullmessage = 'Error Trace: Sep 14 2021 - 23:19:17, Stream.cpp ...ould not find image to release Error code = -1013' message = 'Could not find image to release' with_traceback =

The above is a description of an error in a Python program. Here is the original traceback:

Traceback (most recent call last): File "scAnt.py", line 1222, in checkActiveStackThreads img[0].Release() File "C:\Users\basnagala.1\Anaconda3\envs\scAnt\lib\site-packages\PySpin\PySpin.py", line 36147, in Release return _PySpin._SWIG_ImgPtr_Release(self) _PySpin.SpinnakerException: Spinnaker: Could not find image to release [-1013]

Displaying progress! Displaying progress! Displaying progress! Captured Image with width = 5472, height = 3648 Time to write image to device: 1.5997185707092285 seconds Displaying progress! Moving stepper Z to position -10500 Captured Image with width = 5472, height = 3648 Time to write image to device: 1.5438306331634521 seconds Displaying progress! Moving stepper Z to position -10000 Captured Image with width = 5472, height = 3648 Time to write image to device: 1.754715919494629 seconds Displaying progress! Moving stepper Z to position -9500 - Motor Did not move to -9500

FabianPlum commented 2 years ago

The capture time seems correct. A complete scan of about 4000 images takes on average about 2 hours and with a capture time of roughly 1.6 seconds per image that appears fine.

Did you take out one of the rings now? The scanner cannot autofocus the images, you need to set the focus and range to the closest and furthest focal plane the specimen appears sharp in. Vary the step-size based on the focal overlap between images for a smoothly stacked final shot. Keep in mind, the smaller the step-size (in the Z axis in this case) the more images you will take.

For a specimen of the size you have in the scanner above, you should capture roughly 20 images per orientation at a F5.6 - F8 aperture.

henrikmyl commented 2 years ago

Scanning is "slow" that is "true", but that is still best what we have and this is really big thing!!! Big, Big thanks for Fabian and other group!! They started build this wonderful machine!!

[sbasnagala] you have many things wrong, please read https://peerj.com/articles/11155/ at least several times.

I attached link to my machine settings (easyupload link under). White balance is not perfect, but this is the "rame" which i like to use. Maybe this will help you?

https://easyupload.io/dcshah

sbasnagala commented 2 years ago

I am running the scanner with 2 rings now. The image is focused now, the scanner took 22 images as it moves backward and all the images are blurry. Gimble arc moved to the position perpendicular to the ground and the camera moved forward and stopped at -19000. The image is not focused on his point. Are you saying to re-scan the specimen with different focal points by manually stopping the scanning process?

[henrikmyl] - Thanks for the comment, I must read the paper again at some point I guess. I clicked the link but could not find the machine settings. image 5

FabianPlum commented 2 years ago

Hi Suranga,

At the distances, you have set in the software and the size of your specimen, you should only use one extension ring. Again, the scanner does not automatically focus the image for you. You need to drive the Z-axis (the camera) back to the furthest focal distance you need, for example, -20000 (this is just an example and may not be the value for your specific use-case). Then, you need to adjust the focus on the lens. The scanner software cannot physically change the focus on your camera; you need to adjust this for the first position yourself. This closest focal point is your Min [Z Axis] value.

After you have done that, with the closest point of the specimen in focus, slowly drive the Z-axis forward until the point furthest away on the specimen is in focus. Note down the value of the Z-axis - this is now your Max [Z Axis] point.

Depending on the geometry of your specimen, you may want to repeat the process for different X and Y orientations.

When you have set up the scan correctly, you should not have to interfere with the scanning process manually.

All the best Fabi

FabianPlum commented 2 years ago

I will close this thread for now, as the discussion no longer relates to the original topic [Slow scanning progress]

If you continue to have issues getting images in focus, please open a new issue thread!