Sunday, September 15, 2019
ways to increase OpenCV fps
One way to increase the fps of the OCT software might be via multi-threading - using a separate thread to poll the camera as in
https://www.pyimagesearch.com/2015/12/21/increasing-webcam-fps-with-python-and-opencv/
Another way might be the cufft library?
https://www.researchgate.net/post/How_efficient_are_the_parallel_2D_FFT_implementations
Saturday, September 14, 2019
tutorial on 360 to dome with Vuo on Mac
In the second half of this tutorial, Paul talks about warping 360 videos to dome -http://paulbourke.net/dome/vuo/
Edit: Can now use OCVWarp and do this ...
Thursday, September 12, 2019
system program problem
Popup on startup - System Program Problem detected. The solution was to clear /var/crash as per this post.
Saturday, September 07, 2019
increasing font size in Octave legend
Some figures created in Octave had very small font sizes when added to the LaTEX manuscript. Trying to fix the text with Inkscape led to kerning issues similar to this post. So, found these solutions at
https://stackoverflow.com/questions/1532355/increase-font-size-in-octave-legend
Used commands like
print ("j0exp.eps", "-depsc", "-F:20")
Tuesday, September 03, 2019
starting offline processing in a new thread - C++
Tried various options to begin processing in a new thread for BscanFFT, without locking the UI -
Just
std::system(offlinetoolpath);
// - this causes the BscanFFT program to wait for the offline tool to finish
Then,
pid = fork();
if (pid == 0)
{
// child process
std::system(offlinetoolpath);
}
else if (pid > 0)
{
// parent process
}
gives the error
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
BscanFFTspinj.bin: ../../src/xcb_io.c:259: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Apparently, system specific is safer, http://www.cplusplus.com/forum/beginner/13886/
"Actually, the most important disadvantage of system() is that it introduces security vulnerabilities. Using a system-dependent method (that skips the shell) is always safer.
In Windows, it is CreateProcess(), which is really straight-forward to use.
In POSIX (Linux, etc) it is a combination of fork() and one of the exec() functions.
http://linux.die.net/man/2/fork
http://linux.die.net/man/2/execve
http://linux.die.net/man/3/execv
These are also easy to use, but there are some caveats. Follow the example codes."
execve with the example code gave
(show:9323): Gtk-WARNING **: 10:47:16.601: cannot open display:
suggested using execv instead. This worked.
external hard disk prices
The 3TB drives seem to be attractively priced due to the sharp drop in per TB price as compared to 2TB drives.
Monday, September 02, 2019
gimp 16-bit caution
On Linux,
file filename.png
gives information about the file, like bit-depth and so on.
Sunday, August 25, 2019
smorgasbord of programming tips and ideas - OpenCV etc
- CUDA and OpenCV - just need to compile OpenCV on a machine with a Cuda compatible graphics card. My old machines have cards which are only supported by older versions of the CUDA SDK. Can expect a 180% speedup as per some papers.
https://answers.opencv.org/question/62955/cudadft-speed-issues-too-slow/
indicates that the Matlab times were wrong.
https://opencv.org/cuda/
https://developer.nvidia.com/cuda-gpus and legacy gpus at
https://developer.nvidia.com/cuda-legacy-gpus
https://developer.nvidia.com/cuda-toolkit-archive and supported GPUs at
https://en.wikipedia.org/wiki/CUDA#GPUs_supported - A nice class to capture from Spinnaker SDK to OpenCV Mat, running in a separate thread - https://github.molgen.mpg.de/MPIBR/SpinnakerCapture
- Writing an OpenCV Mat file to a binary format on disk - Lots of options mentioned at
https://answers.opencv.org/question/6414/cvmat-serialization-to-binary-file/ - I had a thought of trying DICOM writing. But it turned out to be quite complicated to write DICOM, since so many parameters need to be initialized.
https://stackoverflow.com/questions/36379637/read-dicom-in-c-and-convert-to-opencv
https://github.com/marcinwol/dcmtk-basic-example
https://itk.org/ITKSoftwareGuide/html/Book2/ITKSoftwareGuide-Book2ch1.html#x7-240001.12
https://www.researchgate.net/post/ITK_vs_OpenCV - Some tips on exporting from Octave to OBJ and STL formats - commonly used in 3D printers - https://alexbjorkholm.wordpress.com/2016/10/07/exporting-3d-objects-from-octave/
- Plotting using slice in Matlab -
https://stackoverflow.com/questions/35549733/how-can-i-plot-several-2d-image-in-a-stack-style-in-matlab
Ubuntu 18.04 screen issue for File Open dialog boxes, scrollbars [fixed]
Apparently, 18.04 configures 2 screens even when there is only one screen. Fix was to go to Settings and change to one screen.
Still there is a problem with Geany's scrollbars - the scrollbars don't redraw after scrolling, leading to the whole scrollbar becoming an orange colour instead of just the orange scrollbar handle. My initial installation was a minimal Ubuntu desktop. Later, installing unity did not help.
Edit: This post seems to have the solution - installing a newer version of Geany from the ppa solved the scrollbar issue.
sudo add-apt-repository ppa:geany-dev/ppa
sudo apt-get update
sudo apt-get install geany geany-plugins-common
Friday, August 23, 2019
Visual Studio specifics of OpenCV project with Spinnaker SDK
- The SDK and examples installed by default under Program Files in C:. If Visual Studio opens the examples there, it complains that the directory is not writable. So, make a copy, including the entire spinnaker directory - not just the src folder, since the include paths in the examples are set as ..\..\include and similarly for libs.
- In my case, since I had VS2017, I had to install the VS2015 toolset as mentioned in my previous post, and when opening the solution, choose the "No Upgrade" option for these projects.
- Once these steps were done, I could compile and run the examples. But for my project, I had to create a new project, choose the V140 toolset, add libraries, add include and lib paths, and also prevent errors due to my use of sprintf.


- One way would have been to make a copy of the common properties file which I had made earlier, make modifications to it, and add that to the project. In this case, I just made specific changes to the Release configuration of this particular project.
- Additional include dir in C/C++ -> General, Additional Include Directories would be a better place to add it than in this screenshot.

- Linker -> Input -> Additional Dependencies

- Additional Library Directories.

implementing opencv project with Spinnaker SDK for Point Grey FLIR cameras
- On both Windows and Linux, I had to make changes to my build platform. On Linux, Ubuntu 18.04 was a supported platform, so I installed 18.04 onto a spare partition. On Windows, I was using Visual Studio 2017, and had to install the VS2015 toolset.

- On Linux, even though the spinnaker examples had large and complex makefiles, the sdk had put the include and lib files in the default locations, so I just had to modify my CMakeLists.txt file minimally -
- On Windows, there was a much more elaborate series of steps, which I will put in a separate post.
- The simpler parts of implementation, like changing exposure time, gain etc could be done in a fairly straight-forward way. Unfortunately, there was no example for continuous capture with live display. ptgrey.com being redirected to flir.com, the examples obtained on googling couldn't be directly found. Finally, found this, which indicated that StreamBuffer handling had to be changed. Looking for this specific information, found the documentation at this page, which mentions its potential use in live view scenarios. Putting that in place, then Begin Acquisition and End Acquisition could be implemented outside the capture loop, and the frame rate improved.
(Gain is in dB)
In terms of nodes,
AcquisitionControl -> AcquisitionMode -> Continuous
AcquisitionControl -> ExposureAuto -> Off
AcquisitionControl -> ExposureTime -> 1000
AnalogControl -> GainAuto -> Off
AnalogControl -> Gain -> 0.0
AnalogControl -> Gamma -> 1.0
ImageFormatControl -> Width -> 1280
ImageFormatControl -> Height -> 960
ImageFormatControl -> OffsetX -> 0
ImageFormatControl -> OffsetY -> 0
ImageFormatControl -> PixelFormat -> Mono8
ImageFormatControl -> PixelFormat -> Mono16
ImageFormatControl -> AdcBitDepth -> Bit12
ImageFormatControl -> AdcBitDepth -> Bit10
BufferHandlingControl -> StreamBufferHandlingMode -> NewestOnly
Using Displayspin, on my machine, I got
71 fps for Bit12 Mono8
34 fps for Bit12 Mono16 (converted to Mono8 to display on screen)
71 fps for Bit10 Mono8
So, probably we can always use Bit12, since it does not seem to have much of a speed penalty.
And a small note on a mistake I made - initially I got the error
Spinnaker: Can't clear a camera because something still holds a reference to the camera [-1004].
Putting pCam = nullptr; before camList.Clear(); removes this error.
Wednesday, August 21, 2019
IP address, MTU setting on Linux for FLIR Point Grey GigE cameras
Even after setting up a larger MTU with ifconfig,
https://www.flir.com/support-center/iis/machine-vision/knowledge-base/lost-ethernet-data-packets-on-linux-systems/
the MTU reverted back to 1500. So, probably hardware or driver limited.
Also, Network Manager then complains that the interface is not managed,
https://askubuntu.com/questions/71159/network-manager-says-device-not-managed
But the camera works as long as the IP address is set correctly. According to the knowledge base article at
https://www.flir.in/support-center/iis/machine-vision/knowledge-base/setting-an-ip-address-for-a-gige-camera-to-be-recognized-in-linux/
setting it anywhere in the 169.254.x.y range with a 255.255.0.0 netmask should do the trick - link local address (LLA).
More info about our camera is at
https://www.flir.com/products/blackfly-s-gige/?model=BFS-PGE-16S2M-CS
https://www.flir.com/support-center/iis/machine-vision/knowledge-base/technical-documentation-bfs-gige/
Getting Started Manual which talks about Windows installation
Technical Reference which gives frame rates, pin-outs etc
Edit - found this page which has a good explanation of the bandwidth used, effect of lower MTU (slightly higher CPU usage), multiple GigE cameras and so on.
Sunday, August 18, 2019
Remmina, RDP and sound
tried ubuntu install from mint
https://help.ubuntu.com/lts/installation-guide/i386/apds04.html
but apt update after chroot seemed to be taking the values from sylvia.
So, simpler to just use a bootable usb to create and install the new ubuntu partition.
Wednesday, August 14, 2019
moving mailing list to google groups
Had asked PB to unconfirm users who have been moved to groups instead of unsubscribe, because unsubscribe will send them a mail saying they have been unsubscribed.
Points to note:
(a) any user you add will get an email
(b) for a strictly mailing list only functionality, remove posting permissions for everyone except owner and manager, under Permissions -> Posting Permissions, like
Google groups does handle bounces, and it is advisable to remove ids which bounce -
https://productforums.google.com/forum/#!msg/apps/5PCc-uDVowo/S4A4YPnnzXcJ
(Automating signup though google docs or google forms or something would be great. An example is given here,
https://sites.google.com/site/sandorexampleclub/how-to/step-11
PS wrote his own implementation which is on script.google.com as a GSuite script, I think.)
Tuesday, August 13, 2019
easy 3D volumetric rendering with imagej
Monday, August 12, 2019
creating animated gif or video from Octave
This post has some good guidelines - using
set(0, 'defaultfigurevisible', 'off');
to speed up things, and using print to save as png. Then using mencoder etc to create the movie.
mencoder mf://output/*.png -mf w=640:h=480:fps=25:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi
Sunday, August 11, 2019
bulk renaming from commandline on linux
rename 's/\.html$/\.php/' *.html
Tuesday, July 16, 2019
using DMCTK with CMake on Linux
find_package(OpenCV REQUIRED)
find_package(DCMTK REQUIRED)
include_directories($(USB_1_INCLUDE_DIR))
include_directories($(OpenCV_INCLUDE_DIR))
include_directories($(DCMTK_INCLUDE_DIRS))
... snip ...

