Simplest possible slideshow software with custom interval time down to millisec. - Page 1
Forum section: electronics / general

author: ricko_uk
author_rank: Super Contributor
timestamp: December 17, 2020, 11:29:53 pm
content: Hi,I just joined this forum so hopefully I am posting in the right area and according to the guidelines.I have not used Visual C++/MFC in 18 years... So the simplest and fastest coding solution for the software below is what I am looking for. Not even menu, open/save or anything else. Something I can make ideally in a day or even just few hours...In summary I want to make (using VC++) the following:1) a slideshow that displays a set of images in a random order. Such images are located in the same folder where the EXE file is located2) the images are displayed in RANDOM sequence for XX number of times at RANDOM YY time intervals (from tens of milliseconds to seconds)3) the ONLY two UI items are the Play Slideshow button and a small table where in each row I specify a) the number that a full set of images in the folder is displayed, b) minimum display time in milliseconds and c) maximum display time again in millisecond. (note, it will be always at least 10 milliseconds display time minimum).4) it is just for me so a single EXE file with NO installer, no fancy UI, no open file, no images location folder choosing, no save of settings or anything else. I can fill in the table every time I run the software.5) only in WindowsThe goal is to make it as fast as possible. Hopefully just few hours??The main issue I have not used Visual C++ for over 18 years so don't remember much about it.Can you please give me some pointers as to how to implement it.Thank you

author: JohnnyMalaria
author_rank: Super Contributor
timestamp: December 17, 2020, 11:51:09 pm
content: Dusting off the cobwebs of my VC++ days and writing real-time video processing software, you will quickly run into the problems associated with the fact that Windows is not a real-time operating system. Although there are simple Sleep commands, they have at best 1ms precision, often 10ms and it depends on the hardware the OS is running on. And there's no guarantee Windows will return to your process after the requested interval.So, you have it get into the painful world of high precision multimedia timers etc. Trying to get Windows to do anything on your terms as far as timing goes is pretty much impossible because it decides what processes and threads to start and suspend, and when.,This will give some idea:https://www.codeguru.com/cpp/w-p/system/timers/article.php/c5759/Creating-a-HighPrecision-HighResolution-and-Highly-Reliable-Timer-Utilising-Minimal-CPU-Resources.htmWhat I would do is create a memory mapped file, write a series of images to it and then use Win32 API media player functions to play a video. Basically, set up a memory mapped file as a circular buffer. I'd probably use an AVI container with uncompressed YUV images and keep changing the contents of the buffer. By using a video, you can set a frame rate. I don't know how high a frame rate could be achieved. You are effectively asking for up to 100 frames per second.Alternatively, you spawn a separate thread that just keeps polling the high precision timer and calls your main thread when a certain time has elapsed. You need to be smart about that, though, to avoid excessive CPU use etc.Just a consciousness stream that brought up some painful memories

author: ricko_uk
author_rank: Super Contributor
timestamp: December 18, 2020, 12:33:17 am
content: Thank you Johnny,that is very interesting and although it all makes sense, I would have no idea where/how to start to implement it.I can relax the minimum time to perhaps 50ms. But for the first version timing accuracy is not that critical, at least for this version.Someone suggested getting some example code of the simplest possible slideshow and try to tweak that. But no idea where to find such examples that are extremely simple for me to understand the code of.Any ideas where?Thank you again!

author: DrG
author_rank: Super Contributor
timestamp: December 18, 2020, 12:45:49 am
content: I would look into tachistoscope as a search key word rather than slideshow. I would think that you will need to load in all your images into memory and do a lot to deal with timing. Just looking around for a bit I found this jpg (from 1999) that even as some source code.https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiikYvFptbtAhUN11kKHdt7D4EQFjADegQIBxAC&url=https%3A%2F%2Flink.springer.com%2Fcontent%2Fpdf%2F10.3758%2FBF03207728.pdf&usg=AOvVaw2HfPjCAytXYizylBB2WwS_Not much help I suppose but it could reveal a few helpful items

author: ricko_uk
author_rank: Super Contributor
timestamp: December 18, 2020, 12:53:30 am
content: Thank you Drg.Very interesting about the tachistoscope.That link does now work, could you please check it?I also google tachistoscope but could not find much about software.

author: DrG
author_rank: Super Contributor
timestamp: December 18, 2020, 01:14:57 am
content: Quote from: ricko_uk on December 18, 2020, 12:53:30 amHmmhttps://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjR8fPtq9btAhUo01kKHX5BBlUQFjABegQIAxAC&url=https%3A%2F%2Flink.springer.com%2Fcontent%2Fpdf%2F10.3758%2FBF03207728.pdf&usg=AOvVaw2HfPjCAytXYizylBB2WwS_That works for me and opens up the prompt for how you want to load it - firefox or adobeIt is a journal article and you can see the reference herehttps://pubmed.ncbi.nlm.nih.gov/10495818/but for the full pdf either get that link to work or put "The PC tachistoscope has 240 pages" into Google and the pdf link will come up from springer.Here is another refhttps://www.semanticscholar.org/paper/Tachistoscopic-presentation-and-millisecond-timing-Haussmann/4405b50ccabec6d193187fdb2f83e7b30bc99e7dyou will need to request a reprint or otherwise find the article.Years ago, there were many labs into using PCs for this. It sounds like you may want something that specific. Good luck.Edit: try the link herehttps://www.semanticscholar.org/paper/The-PC-tachistoscope-has-240-pages-Myors/cd20f576f738f83eaa457d4d6918baaf0ebf0958

author: ricko_uk
author_rank: Super Contributor
timestamp: December 18, 2020, 04:21:08 pm
content: Thank you very much DrG!It was not working on Chrome or Firefox (not even the pop-up) but managed to open it with Edge.Very interesting. Thank you

author: snarkysparky
author_rank: Frequent Contributor
timestamp: December 18, 2020, 04:40:58 pm
content: you can use octave or matlab to create a video from a string of image files. Each with a programmed number of video frames to display the image.So your video is composed of still images repeated for random durations.

author: ricko_uk
author_rank: Super Contributor
timestamp: December 18, 2020, 05:12:42 pm
content: Thank you snarkysparkyThat is an interesting solution! Unfortunately I haven't used matlab since over 20 years ago and would have to start pretty much form scratch. And that might be longer to re-learn perhaps?

author: JohnnyMalaria
author_rank: Super Contributor
timestamp: December 18, 2020, 05:14:59 pm
content: ricko_uk - just to give you a taste of some of the fun and games you'll likely face...Achieving the most mundane of goals with VC++ can take forever. With the SDKs, you get access to the Win32, GdiPlus APIs etc. Something as trivial as displaying a bitmap can get tedious to program and slow to execute. Displaying a single image requires rendering in your main RAM. The OS then sends it to the display's buffer. To get higher performance, you can use APIs such as DirectDraw and DirectShow (caveat - it's been a few years since I last did any of this so I don't know the current state of things). These permit, for example, direct rendering to the GPU RAM. But these two frameworks rely heavily on interface libraries. If you haven't used those before and you are in the VC++ environment, oh boy. It is very powerful but very tedious to program and hell to debug.One option to consider, is the DirectShow framework and the Filter Graph concept. With this, you effectively write a plug-in and the framework takes care of all the timing, rendering etc. It's powerful but has a s-t-e-e-p learning curve. I wrote an application using these concepts that processed DV format video in real-time, either from a file or an external DV source. Microsoft provides all the low-level stuff such as controlled the transport of the hardware, file transfer, audio rendering etc etc.For your application, a DirectShow application would be lightweight. Most of my effort went into the user interface and the help file

author: JohnnyMalaria
author_rank: Super Contributor
timestamp: December 18, 2020, 05:20:48 pm
content: I attached an example of a lab instrument I developed that used the DirectShow/Filter Graph concept to characterize the flow of powders. It required comparing consecutive frames arriving in real-time from a camcorder every 30ms. The filter I wrote performed all the calculations and dumped the results to a text file.

author: BravoV
author_rank: Super Contributor
timestamp: December 18, 2020, 05:36:54 pm
content: Not sure if this fits into the requirement ->https://sourceforge.net/projects/jpegview/Suggesting try download, install and read the .INI file, its one of the fastest image file viewer in Windows as it supports multicores, the slide show speed can be set up to 100fps, and almost no menu at all, or at least very minimalist approach.Again, once installed, suggesting to read the JPEGView.INI file at the program's folder where it was installed, it has whole documentation there.Btw, its open source.

author: ricko_uk
author_rank: Super Contributor
timestamp: December 18, 2020, 07:26:38 pm
content: Thank you Johnny and BravoV.BravoB that is almost exactly what I am looking for! If it could set different display duration times at different times during the slideshow (i.e. first x minutes transition time is 1 second, then for y minutes it is 0.2 seconds etc.) then that would be exactly what I am looking for!Thank you VERY much!