ZELLMECHANIK-DRESDEN / ShapeOut

Shape-Out has been superseded by Shape-Out 2.
https://shapeout.readthedocs.io
GNU General Public License v2.0
5 stars 5 forks source link

Doesn't show images of cells with index > 29,122 #129

Closed phidahl closed 7 years ago

phidahl commented 7 years ago

0.7.0dev16 (32 and 64 bit) don't show the image of a cell, if its index is > 29,122.

paulmueller commented 7 years ago

I do not observe this with Ubuntu. Does this happen on Mac OSx and on Windows?

phidahl commented 7 years ago

only windows.

not on MacOS

Von meinem Telefon gesendet

Am 21.02.2017 um 18:58 schrieb Paul Müller notifications@github.com:

I do not observe this with Ubuntu. Does this happen on Mac OSx and on Windows?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

maikherbig commented 7 years ago

It might be a bug of OpenCV. Using imageio (https://pypi.python.org/pypi/imageio) it is possible to get images from larger .avi files

paulmueller commented 7 years ago

@maikherbig Does imageio load the entire video file into memory or can it access individual frames at a time? If the memory footprint is small and it works with pyinstaller, I would work on migrating to imageio. Could you please share your imageio code here?

paulmueller commented 7 years ago

@maikherbig I tested imageio, but it seems to have issues seeking through the avi (at least on Ubuntu). Could you please verify the following code on Windows?:

import imageio
import numpy as np

cap = imageio.get_reader("path/to/file.avi")
img0 = cap.get_data(0)
img1 = cap.get_data(2000)
img2 = cap.get_data(0)
assert np.all(img0==img2), "repeatedly reading first frame works"
assert np.all(img1==0), "seeking to a high index results in zero image"

I have implemented a workaround by iterating through the video with steps of 50 frames. But this makes image reading quite slow: https://github.com/ZELLMECHANIK-DRESDEN/dclab/commit/995c867b71ce521112b2547e8e54daf1bbdda787

If this problem is not present on Windows, then we could move to imageio. I am starting to think that this is an ffmpeg problem.

paulmueller commented 7 years ago

We should move to imageio once the new rtdc file format is implemented. Then, we can convert the tdms/avi data to hdf5 in one run and won't have this seeking problem.

maikherbig commented 7 years ago

@paulmueller I have tested the code above:

np.all(img0==img2) Out[9]: True

np.all(img1==0) Out[10]: False

On windows it seems to work fine. On my machine there is just a window popping up (ffmpeg.win32.exe) anytime the imageio.get_reader function is called.

paulmueller commented 7 years ago

It looks like the problem I had only appears with avi files that are somehow broken (e.g. VLC player offers to repair something about it).

paulmueller commented 7 years ago

I removed the OpenCV from ShapeOut. Could you please test the binary: https://ci.appveyor.com/project/paulmueller/ShapeOut/build/job/x8mgeunt9al0p8ds/artifacts

And let me know if

Writing videos with imageio seems to be simpler than with opencv. The output video is now "rawvideo" with the "gray" pixel format.

maikherbig commented 7 years ago

Displaying event images work, but there is always the ffmpeg-win32-v3.2.4.exe window popping up when a new cell is clicked (very annoying). Exporting images works. Unfortunately it is not possible anymore to open the file then with VirtualDub (Error: Error reading source from frame 0: Error decompressing frame 0:...the video data is too short). Opening in VLC works just fine. It nicely shows the images of the cells as a video

paulmueller commented 7 years ago

I modified the sp.Popen calls in imageio (https://github.com/imageio/imageio/issues/266). These windows should not appear anymore: ~https://ci.appveyor.com/project/paulmueller/shapeout/build/1.0.628/job/fsvem025dfbavyjs/artifacts~ https://ci.appveyor.com/project/paulmueller/shapeout/build/job/rk7b3h2onsxs3q26/artifacts

[EDIT] @maikherbig I just triggered a new build for the commit above that uses a different pixel format (YUV 4:4:4) in dclab. Maybe that fixes your VirtualDub problem.

maikherbig commented 7 years ago

I tested it and all problems are solved now :) No popup windows anymore and there is now support for a variety of video-players.