Thursday, November 07, 2019

virtual tours with 360 photos, and panoramas

Thought about creating a virtual tour of the planetarium with the Insta360 Air camera. This camera works reasonably well in good light, but cannot capture in low light as is the case inside the planetarium theatre - severely pixelated with the lights on, and completely dark when trying to capture the live planetarium show.

Saw some tutorials using cupix and google tour creator, then made one with google tour creator,
https://poly.google.com/view/6fr4ibdUbv0

Added the same images (after resizing to 4K) to google street view using the street view app. To change the directions in which the 360 images are pointed, under Edit location, the photo can be rotated by swiping while keeping another finger on the directions (N, NE, E etc.) shown below, to keep the directions steady. A bit fiddly. Positioning was also a bit fiddly, since the zoom level on the positioning map was not sufficient in my case.

Made a couple more panoramas, both using the Panorama feature in the stock camera app on my LG Q6 Android phone and using the street view app. The street view app tries to stitch it into a 360 image, so requires a very large number of photos.
Shot with the Google Street View App, which needs you to align the phone to a shown circle and click repeatedly.

Shot with the Panorama feature of the phone's camera App, which needs you to just wave your phone from left to right or vice versa. 
Also shot with the Panorama feature on the phone camera. A passerby created an artifact, so repeated below. 




stackoverflow gyaan on when to use GPU

getting a human being with HDFC phonebanking

It seems a bit difficult to get a human being using the HDFC bank tollfree number. One possible workaround is - choose the "Loans" option. If that option does not appear on the first menu, try the "Report stolen card" option, and when they ask for confirmation, choose "2 for any other services" and then "Loans". After a human being answers, you could tell them what you want, and if they say that they need to transfer your call, agree.

Thursday, October 31, 2019

GPU and CUDA explorations with OpenCV


Bscancompute
    While loop 9.01159 sec.
      While loop 12.5376 sec.
        While loop 13.7008 sec.

            2nd run
              While loop 9.03921 sec.
                While loop 8.88572 sec.
                  While loop 8.32227 sec.

                      Test wo FFT,
                        Before while loop 0.0226007 sec.
                          While loop 3.82644 sec.
                            While loop 3.6609 sec.
                              While loop 3.07903 sec.

                              • A simple sample program, to perform a 2D DFT and inverse, gave the following results on running more than once -
                              • samplecudadft,
                                480x360 fft and inv fft
                                DFT and inverse, with upload/dl 0.255261 sec.
                                (after running several times).

                                2400x360,
                                DFT and inverse, with upload/dl 0.261917 sec.

                                CPU
                                E:\OCT\opencvcuda\OpencvCuda\x64\Release>samplecudadft
                                DFT and inverse, on CPU 0.0144597 sec.
                                DFT and inverse, with upload/dl 0.260429 sec.
                              • bottleneck seems to be FFT "planning" and not upload download.

                                E:\OCT\opencvcuda\OpencvCuda\x64\Release>samplecudadftDFT and inverse, on CPU 0.0146046 sec.
                                DFT and inverse, with upload/dl 0.263986 sec.
                                DFT and inverse, without upload/dl 0.260521 sec.
                                and running it a 2nd time,
                                DFT and inverse, 2nd time without upload/dl 0.00618453 sec.
                              • Even when called as a function, quite fast after the first time.
                                DFT and inverse, as a function 0.00678208 sec.
                                DFT and inverse, as a function 0.00605592 sec.
                                DFT and inverse, as a function 0.00654344 sec.
                                DFT and inverse, as a function 0.00608254 sec.
                                DFT and inverse, as a function 0.00651554 sec.
                                DFT and inverse, as a function 0.00623649 sec.
                                DFT and inverse, as a function 0.00607195 sec.
                                DFT and inverse, as a function 0.0063154 sec.
                                DFT and inverse, as a function 0.00597894 sec.
                                DFT and inverse, as a function 0.00685649 sec.
                                DFT and inverse, as a function 0.00608895 sec.
                              • Will probably need to optimize based on
                                https://docs.opencv.org/master/dd/d3d/tutorial_gpu_basics_similarity.html
                              • Currently, with upload / download and variable assignment not optimized,
                                on cpu,
                                While loop 9.15065 sec.
                                on gpu,
                                While loop 9.34765 sec.
                                where variables were initialized, 64 to 32 conversion and back were included.

                                More important, the Bscan image shows up a bug.

                              Friday, October 25, 2019

                              a workflow for equal loudness RMS normalization on Adobe Audition

                              Sat with the Telugu team and worked out the following procedure for increasing and standardizing the RMS volume of their audio to -12 dB in Adobe Audition.


                              1. Match the volumes in the relevant regions to around -12 dB peak.
                              2. Do Noise Reduction by selecting a region of audio without noise, and then using that as the noise to be removed, around 70% or 80%.
                              3. Noise Gate at -60 dB - the threshold to be tweaked depending on audio's background noise level.
                              4. Choose either L or R track and mute the other track if relevant audio is only on one track, then convert to Mono.
                              5. Multiband compression using the Broadcast preset, and decreasing the thresholds by -20 dB, with Brickwall On.
                              6. Reverb filter if required.
                              7. Total RMS to -18 dB.
                              8. Hard Limiter at -6 dB.
                              9. Normalize peaks to 100%.


                              Tuesday, October 22, 2019

                              UTF-16 LE with BOM and compiler errors, warning: null character(s) ignored

                              By some fluke, the source code which I had edited on Windows got saved on github as UTF-16 LE with BOM (as reported by Geany). This was not compiling on Linux, which gave lots of warnings,

                              warning: null character(s) ignored

                              Googling got the UTF to UTF convertor on www.fileformat.info which converted the file properly to UTF-8. Problem solved.

                              Saturday, October 12, 2019

                              clearing up GMail used space

                              Change of 16.21 GB to 16.11 GB by deleting 8893 conversations from Trash, most of them short text-only email notifications.

                              100 MB for 10,000 short text emails, or around 10 kB per email.

                              So, probably it does not make sense to delete small emails - deleting attachments would clear up much more space.

                              Monday, October 07, 2019

                              X windows issues after CUDA install, resolved

                              Since my machine is supposed to have a GeForce GT 330M according to lspci, I thought I could try out the old version of CUDA SDK - apparently version 6.5 is the last one to support the GT 330M. The deb was supposed to be for Ubuntu 14.04, and I was running Linux Mint 18.1 based on Ubuntu 16.04. The deb and the apt-get install ran without any complaints. But ...

                              The build of examples worked, but the the cuda compatible nvidia card was not detected. And, after a restart, X did not come up.

                              Possible culprit was the NVidia driver for the older 14.04 kernel, which probably needed to be removed and so on. After some googling and some trial and error, the following method worked -

                              sudo apt purge nvidia*
                              sudo apt-get update 
                              sudo apt-get autoremove
                              sudo apt-get upgrade
                              sudo apt-get install --reinstall xserver-xorg-core
                              sudo apt-get install --reinstall xserver-xorg-video-nouveau

                              and a reboot. 

                              Sunday, September 22, 2019

                              WhatsApp notification issue and solution

                              On my LG Q6 phone, running Android 8, there was a problem of WhatsApp notifications arriving only after I opened WhatsApp. WhatsApp voice call notifications were also not coming through. After some digging, found the setting which made the difference - under Battery -> Power saving exclusions, allowed WhatsApp as an exclusion. Problem seems to be solved.

                              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:

                              https://stackoverflow.com/questions/2437819/gtk-warning-cannot-open-display-when-using-execve-to-launch-a-gtk-progra/2437850#2437850

                              suggested using execv instead. This worked.


                              external hard disk prices

                              From amazon.in, current external USB hard disk prices which I collected for N -
                              1 TB = Rs. 3500 - per TB cost 3500
                              2 TB = Rs. 5100 - per TB cost 2550
                              3 TB = Rs. 6200 - per TB cost 2067
                              4 TB = Rs. 8100 - per TB cost 2025

                              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

                              Gimp 2.8 opens 16-bit png files, but saves as 8-bit tif or png. Octave 4.2.2 on the other hand, does write 16-bit png with imwrite. Octave's behaviour depends on shared libraries, too, of course.

                              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

                              Here is a collection of links for various implementations of OpenCV-based medical imaging software -

                              1. 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

                              2. A nice class to capture from Spinnaker SDK to OpenCV Mat, running in a separate thread - https://github.molgen.mpg.de/MPIBR/SpinnakerCapture
                              3. 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/
                              4. 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

                              5. 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/
                              6. 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]

                              After a new install of Ubuntu 18.04, had a funny problem where Geany File Open would lead to the application being greyed out, as if the dialog box had opened, but no dialog box being visible on screen. Googling found the answer in this thread, https://ubuntuforums.org/showthread.php?t=2395250

                              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

                              This is linked to my previous post about the QHY -> Spinnaker implementation, the nitty-gritties of Visual Studio project changes required under Windows.

                              1. 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.
                              2. 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.
                              3. 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.


                              4. 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.
                              5. Additional include dir in C/C++ -> General, Additional Include Directories would be a better place to add it than in this screenshot.


                              6. Linker -> Input -> Additional Dependencies


                              7. Additional Library Directories.

                              I would probably need to copy the dlls manually, or follow the post build steps mentioned at this earlier post

                              implementing opencv project with Spinnaker SDK for Point Grey FLIR cameras

                              This post documents my learning curve with migrating code written for the SDK for QHY cameras to the Spinnaker SDK for Point Grey FLIR cameras.

                              1. 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. 
                              2. 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 -


                              3. On Windows, there was a much more elaborate series of steps, which I will put in a separate post.
                              4. 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.  
                              Edit: Here is a dump of the nodes I changed, full code is at https://github.com/hn-88/FDOCT/blob/master/BscanFFTspin.cpp (spinnaker documentation talks about the details of the nodes, and the example code helps).

                              (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.