simonarvin / eyeloop

EyeLoop is a Python 3-based eye-tracker tailored specifically to dynamic, closed-loop experiments on consumer-grade hardware.
GNU General Public License v3.0
479 stars 68 forks source link

check_blink() threshold crash #34

Closed catubc closed 3 years ago

catubc commented 3 years ago

Hi We noticed that for some videos we have that are a bit more messy at the beginning, the standard code crashes on start up. I assume it is setting up some defaults that are not working on the data we have.

Any advice?

Outputting data to /home/cat/data/robin/eye_track_vids/trial_20201111-142930


ValueError Traceback (most recent call last)

in 2 obj = TestIntegration() 3 #obj.pupil_processor.binarythreshold = 100 ----> 4 obj.test_integration(TESTDATA_DIR3, '158002R_LR_eyeball_neg') in test_integration(self, tmpdir, test_video_name) 70 "--output_dir", str(tmpdir)] 71 eyeloop_obj = run_eyeloop.EyeLoop(args=testargs, ---> 72 logger=logger) 73 74 # Ensure output is expected ~/code/eyeloop/eyeloop/run_eyeloop.py in __init__(self, args, logger) 50 importer_module = importlib.import_module(f"eyeloop.importers.{config.arguments.importer}") 51 config.importer = importer_module.Importer() ---> 52 config.importer.route() 53 54 # exec(import_command, globals()) ~/code/eyeloop/eyeloop/importers/cv.py in route(self) 64 65 def route(self) -> None: ---> 66 self.first_frame() 67 while True: 68 if self.route_frame is not None: ~/code/eyeloop/eyeloop/importers/cv.py in first_frame(self) 61 raise ValueError(f"Video path at {self.vid_path} is not a file or directory!") 62 ---> 63 self.arm(width, height, image) 64 65 def route(self) -> None: ~/code/eyeloop/eyeloop/importers/importer.py in arm(self, width, height, image) 31 32 # image = self.rotate(image, self.ENGINE.angle) ---> 33 config.engine.arm(width, height, image) 34 35 def rotate(self, image: np.ndarray, angle: int) -> np.ndarray: ~/code/eyeloop/eyeloop/engine/engine.py in arm(self, width, height, image) 120 config.graphical_user_interface.arm(width, height) 121 --> 122 self.update_feed(image) 123 124 self.pupil_processor.binarythreshold = float(np.min(self.source)) * .7 ~/code/eyeloop/eyeloop/engine/engine.py in update_feed(self, img) 256 self.pupil_source = img.copy() 257 --> 258 self.iterate() 259 260 def cr_artifacts(self, cr_processor, offsetx: int, offsety: int, pupil_area) -> None: ~/code/eyeloop/eyeloop/engine/engine.py in track(self) 171 cr_log = self.cr_log_stock.copy() 172 --> 173 if self.check_blink() is False: 174 blink = 0 175 try: ~/code/eyeloop/eyeloop/engine/engine.py in check_blink(self, threshold) 141 142 if threshold < 0: --> 143 raise ValueError(f"check_blink() threshold must be greater than 0! Threshold was {threshold}") 144 145 # print(f"blink delta = {abs(delta)}") ValueError: check_blink() threshold must be greater than 0! Threshold was -58.0
raghavprasad13 commented 3 years ago

I'm facing a similar issue when I run the eyeloop command.

simonarvin commented 3 years ago

Hi! Can you please link me the video sequence that generates this error? Thanks

Simon Arvin

raghavprasad13 commented 3 years ago

Hi! Can you please link me the video sequence that generates this error? Thanks

Simon Arvin

Hi @simonarvin ! I was trying to run eyeloop directly from the camera right after installing it. Just following the steps in the main README

Raghav Prasad

YangDongJae commented 3 years ago

me too, I have a same issue

simonarvin commented 3 years ago

I pushed a temporary fix to this issue (80972a8).

Until we have a better algorithm for blink detection, you can circumvent any potential errors by manually setting the threshold:

eyeloop --bthreshold [0-255]

Best, Simon Arvin

YangDongJae commented 3 years ago

I pushed a temporary fix to this issue (80972a8).

Until we have a better algorithm for blink detection, you can circumvent any potential errors by manually setting the threshold:

eyeloop --bthreshold [0-255]

Best, Simon Arvin

I pull your src. and now I have a same error message like bellow

heck_blink() threshold must be greater than 0! Threshold was -22.12360961383699

with new error message

You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded. QObject::moveToThread: Current thread (0x7fadc85323b0) is not the object's thread (0x7fad98549460). Cannot move to target thread (0x7fadc85323b0)

how can I do??

YangDongJae commented 3 years ago

and eyeloop --bthreshold [0-255] didn't work on my terminal

simonarvin commented 3 years ago

The Qt error appears to have been fixed by replacing opencv with the headless package: 7da18c2c283912c71ede4cb8e4144e36bab1b09c

Uninstall eyeloop (pip uninstall eyeloop), then reinstall pip install .

How are you changing the threshold? For example, to set the threshold to 10, write: eyeloop --bthreshold 10

Let me know how it goes

Best, Simon

YangDongJae commented 3 years ago

thank you for your comment. I got a trouble shooting. if I get a great solution for it, I will share to you!! thank you guys :)

raghavprasad13 commented 3 years ago

Thank you @simonarvin ! It seems to be up and running now. Just as a suggestion, since this is such a great and useful tool and I foresee a lot of people using it, perhaps you could have a forum for user doubts and issues where people from different academic backgrounds can post their queries without cluttering the GitHub issues page. Perhaps a subreddit for EyeLoop?

catubc commented 3 years ago

This sounds useful.

But we are not using the command line version, is there a way to set this programmatically?

simonarvin commented 3 years ago

@catubc see __init__ in engine.py, specifically # Hard-code blink inference parameters: (188f05a).

self.blink_threshold is the threshold for the mean brightness time derivative. You can play around with this value.

It appears that blinks are pretty distinguishable based on the brightness time derivative. A small threshold tends to detect noisy fluctuations in the mean as blinks. Conversely, a high threshold tends to underestimate blinks. Setting the threshold appropriately and automatically is on our to-do list.

simonarvin commented 3 years ago

This issue should be fixed now; By running eyeloop with the argument tag --blink 1, users can calibrate their blink thresholds to their video sequence. --blink 1 extracts n video frames, from which the user selects all non-blinking frames. The mean and std grayscale distribution is saved and automatically opened by eyeloop on the next run.