Advice to Diabetics

Rujuta Diwekar is the highest paid dietician in India. She is the one who took care of junior Ambani to lose 108 kgs.

Her advice to diabetics:

1. Eat fruits grown locally ….. Banana, Grapes, Chikoo, Mangoes. All fruits have FRUCTOSE so it doesn’t matter that you are eating a mango over an Apple. A Mango comes from Konkan and Apple from Kashmir. So Mango is more local to you.

Eat all the above fruits in DIABETES as the FRUCTOSE will eventually manage your SUGAR

  2. Choose Seed oils than Veggie oils. Like choose ground nut, mustard, coconut & til. Don’t choose chakachak packing oils, like olive,  rice bran etc
Go for kachchi ghani oils than refined oils

  3. Rujuta spends max time in her talks talking about GHEE and its benefits.
Eat GHEE daily. How much GHEE we should eat depends on food. Few foods need more GHEE then eat more and vice versa. Eat ample GHEE. It REDUCES cholesterol.

  4. Include COCONUT. Either scraped coconut over food like poha, khandvi or chutney with idli and dosa
Coconut has ZERO CHOLESTEROL and it makes your WAIST SLIM

  5. Don’t eat oats, cereals for breakfast. They are packaged food and we don’t need them.  Also they are tasteless and boring and our day shouldn’t start with boring stuff.
Breakfast should be poha, upma, idli, dosa, paratha

  6. Farhaan Akhtar’s New ad of biscuits – fibre in every bite… Even ghar ka kachara has fibre, likewise oats have fibre. Don’t chose them for fibre. Instead of oats, eat poha, upma, idli, dosa

  7. No JUICES till you have teeth in your mouth to chew veggies and fruits

  8. SUGARCANE is the real DETOX . Drink the juice fresh or eat the SUGARCANE

  9. For pcos, thyroid – do strength training and weight training and avoid all packaged food

10. RICE – eat regular WHITE RICE. NO NEED of Brown rice. Brown rice needs 5-6 whistles to cook and when it tires your pressure cooker, then why do you want to tire your tummy.

A white rice is hand pounded simple rice

Rice is not high is GI INDEX.  Rice has mediun GI index and by eating it with daal / dahi / kadhi we bring its GI index further down
If we take ghee over this daal chawal then the GI INDEX is brought further down.
B. Rice has some rich minerals and you can eat it even three times a day

11. How much should we eat – eat more if you are more hungry, let your stomach be your guide and vice versa

12. We can eat rice and chapati together or only rice if you wish. It depends on your hunger. Eat RICE in ALL THREE MEALS without any fear.

13. Food shouldn’t make you scared like eating rice and ghee. Food should make you FEEL GOOD


15. No bread, biscuits, cakes, pizza, pasta

16. Ask yourself is this the food my Nani & Dadi ate?  If yes then eat without fear.

17. Eat as per your season. Eat pakoda, fafda, jalebi in monsoon. Your hunger is as per season. Few seasons we need fried food so eat them.

18. When not to have chai – tea – don’t drink tea as the first thing in morning or when you are hungry. Rest you can have it 2-3 times a day …


Three 1/2 minutes

For those who get up at night from sleep to urinate or early in the morning.*

Each individual must take note of the three 1/2 minutes.

Why is it important? Three 1/2 minutes will greatly reduce the number of sudden deaths.

Often this occurs: a person who still looks healthy has died in the night.

Often we hear stories of people who say, “Yesterday, I was chatting with him. Why did he suddenly die?

The reason is that when you wake up at night to go to the bathroom, it is often done in a rush.

Immediately we stand, and the brain lacks blood flow.

Why are “Three 1/2 minutes” very important?
In the middle of the night, when you are awakened by the urge to urinate for example, the ECG pattern can change.

Because in getting up suddenly, the brain will be anemic and causes heart failure due to lack of blood.

You are advised to practice the “Three 1/2 minutes,”
which are:
1. When waking from sleep, lie in bed for the 1st 1/2 minute;
2. Sit in bed for the next 1/2 minute;
3. Lower your legs, sitting on the edge of the bed for the last half-minute.

After three 1/2 minutes, you will not have anemic brain and heart will not fail, reducing the possibility of a fall and sudden death.

PDF Books

In need of any book(.pdf) relating to any subject/field or topic?
Go to your browser and type:
You will get access to millions of  books you need, for free.
Unlimited downloads.

You may browse by title or author, etc.
Currently 274376478 books are available for free and every minute, around 50 new books are added to the database.
All downloads are free.



ONLINE EDUCATIONAL SUPPORT -Tuft University -Univesidad Politechnica, Madrid -Utah State University -University of Michigan -Nore Dame University


■ (
■ AllTheWeb (
■ AltaVista (
■ Ask Jeeves! (
■ Excite (
■ HotBot (
■ LookSmart (
■ Lycos (
■ Open Directory (
■ Google (
■ Mamma (
■ Webcrawler (
■ Aol (
■ Dogpile (
■ 10pht (

■ AnyWho (
■ InfoSpace (
■ Switchboard (
■ (
■ WhoWhere (

■ ABC News (
■ CBS News (
■ CNN (
■ Fox News (
■ New York Times (
■ USA Today (

■ CBS SportsLine (
■ CNN/Sports Illustrated (
■ (
■ FOXSports (
■ NBC Sports (
■ The Sporting News (

■ (
■ kidsDoctor (
■ MedExplorer (
■ MedicineNet (
■ National Library of Medicine
■ Planet Wellness (
■ WebMD Health (

JOURNALS Multidisciplinary – African Journal Online – directory of open access journal – South African Journals. – Open Access Journal Search Engine – Lund University – Free Scientific & Medical Materials – Access & Publication

ACADEMIC SEARCH/WEB RESEARCH TOOLS/REFERENCE MANAGERS – Multidisciplinary – Digital Bibliography Library Browser – Live Search Academic – USA government for Science – Computing & Information Sciences – academic social network/collaboration – Multidisciplinary – Voc & Tech Education – Stanford physics information retrieval system
hsystemv – Social Science Research Network.

The 10th apple effect

A hunter once lost his way deep inside the jungle while chasing a deer.
He used all his navigation skills but neither did he find any way out of the jungle, nor could he find any food to eat for 8 days at a stretch.
He started feeling so damn hungry that he could eat an entire elephant at one go.
Disappointed, he lost all hope. And that is exactly when an apple tree caught his sight.
He collected a dozen apples to feed him for the rest of his search.

As he ate the 1st apple, his joy knew no bounds and he just couldn’t stop feeling grateful and blessed.
He thanked life.
He thanked God.
He could not believe his luck when he ate the 1st apple, but he was less grateful while having the 2nd apple and even lesser grateful when he had the 5th apple.

Somehow, with each passing apple, the hunger still kept on increasing and the joy kept on reducing drastically.
He just could not enjoy the 10th apple.

He had already taken for granted the gift of having found an apple tree in the middle of a forest after 8 long days of wandering with hunger !!
When he took the 10th apple in his hand, he was still very hungry but he just did not feel like having it any more.
Economics calls this diminishing marginal utility…I would like to call it diminishing gratitude…
in simple words, taking things for granted !!
Or let’s just call it the 10th apple effect.

The 10th apple did not lack taste, it did not lack the potential to satisfy his hunger but the only thing lacking was his gratitude for finding food in the middle of the jungle.

The hunter represents us.
And the apple represents the gifts that life gives us.
The 10th apple represents our lack of gratitude for these gifts of life and our ‘take everything for granted’ attitude.

As we continue receiving the gifts of life, our hunger, our greed keeps on increasing and the joy we get from these gifts diminishes.

The 10th apple is as sweet as the first apple.
If the 10th apple fails to give you as much pleasure as the first one, nothing is wrong with the apple, everything is wrong with you !!
If you get bored on a dull day, it is not because the day is dull and boring. It is because your gratitude has become dull and boring.

The gift of life for another day cannot be taken for granted.

The Nth year of life, should seem as exciting as, the 16th year, as the 25th year, as the 50th year….

Never let the ‘10th apple effect’ make you take these gifts of life for granted.
Never let your gratitude for life fade away.

Setting up Machine Learning workstation

NVidia 1060
sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update
sudo apt-get install nvidia-384
sudo apt-get install nvidia-367
sudo apt-get install nvidia-smi

dcml@sun:~$ lsmod | grep -i nvidia
nvidia_uvm            671744  0
nvidia_drm             45056  1
nvidia_modeset        843776  5 nvidia_drm
nvidia              13119488  268 nvidia_modeset,nvidia_uvm
drm_kms_helper        151552  2 i915,nvidia_drm
drm                   352256  5 i915,nvidia_drm,drm_kms_helper

dcml@sun:~$ nvidia-smi
Sat Dec  9 12:49:29 2017
| NVIDIA-SMI 384.98                 Driver Version: 384.98                    |
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|   0  GeForce GTX 106…  Off  | 00000000:01:00.0  On |                  N/A |
| 35%   30C    P8     6W / 120W |    206MiB /  6069MiB |      2%      Default |

| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|    0      1085      G   /usr/lib/xorg/Xorg                           132MiB |

apt-get Update – Hash-Mismatch
sudo apt-get clean
sudo apt-get update
sudo sed -i -re ‘s/\w+\.archive\.ubuntu\.com/’ /etc/apt/sources.list

Open SSH
apt-get install openssh-server


Install path – /opt/anaconda2

Anaconda Clean Remove
conda install anaconda-clean
anaconda-clean –yes
rm -rf ~/anaconda2
rm -rf ~/.anaconda_backup

Open CV with CUDA
apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
apt-get install libgtk2.0-dev
apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
apt-get install libatlas-base-dev gfortran
apt-get install libhdf5-serial-dev
apt-get install python2.7-dev
apt-get install yad

apt-get install build-essential cmake git unzip pkg-config
apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
apt-get install libxvidcore-dev libx264-dev
apt-get install libgtk-3-dev
apt-get install libhdf5-serial-dev graphviz
apt-get install libopenblas-dev libatlas-base-dev gfortran
apt-get install python-tk python3-tk python-imaging-tk

apt-get install python2.7-dev python3-dev
apt-get install linux-image-generic linux-image-extra-virtual
apt-get install linux-source linux-headers-generic

apt-get update
apt-get upgrade

apt-get install python-pip
pip install –upgrade pip

pip install numpy scipy
apt-get install python-numpy python-scipy

wget -O
wget -O

add-apt-repository ppa:jonathonf/ffmpeg-3
apt-get install ffmpeg
  update && apt upgrade

dpkg -i atom-amd64.deb

-D OPENCV_EXTRA_MODULES_PATH=/home/dcml/opencv_build/opencv_cuda/opencv_contrib-3.1.0/modules \

-D OPENCV_EXTRA_MODULES_PATH=/home/dcml/opencv_build/opencv_cuda/opencv_contrib-3.1.0/modules \

make -j 2
sudo make install

apt-get install python-qt4 pyqt4-dev-tools qt4-designer
apt-get install qtcreator
apt-get install qt4-designer
apt-get install python-pyqt5
apt-get install python-qt4 qt4-designer

Run – designer-qt4

dcml@sun:~/Downloads$ sudo bash cuda_8.0.61_375.26_linux-run
Logging to /tmp/cuda_install_9246.log
Using more to view the EULA.
End User License Agreement


The following contains specific license terms and conditions
for four separate NVIDIA products. By accepting this
agreement, you agree to comply with all the terms and
conditions applicable to the specific product(s) included



The NVIDIA CUDA Toolkit provides command-line and graphical
tools for building, debugging and optimizing the performance
of applications accelerated by NVIDIA GPUs, runtime and math
libraries, and documentation including programming guides,
user manuals, and API references. The NVIDIA CUDA Toolkit
License Agreement is available in Chapter 1.

Default Install Location of CUDA Toolkit

Windows platform:

%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v#.#
Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
  [ default is /usr/local/cuda-8.0 ]:

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
  [ default is /home/dcml ]:

Installing the CUDA Toolkit in /usr/local/cuda-8.0 …
Missing recommended library:

Installing the CUDA Samples in /home/dcml …
Copying samples to /home/dcml/NVIDIA_CUDA-8.0_Samples now…
Finished copying samples.

= Summary =

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-8.0
Samples:  Installed in /home/dcml, but missing recommended libraries

Please make sure that
  –   PATH includes /usr/local/cuda-8.0/bin
  –   LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
     sudo <CudaInstaller>.run -silent -driver

Logfile is /tmp/cuda_install_9246.log

apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev
apt-get install libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libglfw3-dev libgles2-mesa-dev

apt autoremove

root@sun:~# cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
root@sun:/usr/local/cuda-8.0/samples/1_Utilities/deviceQuery# make
“/usr/local/cuda-8.0″/bin/nvcc -ccbin g++ -I../../common/inc  -m64    -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery.o -c deviceQuery.cpp
nvcc warning : The ‘compute_20’, ‘sm_20’, and ‘sm_21’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
“/usr/local/cuda-8.0″/bin/nvcc -ccbin g++   -m64      -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery deviceQuery.o
nvcc warning : The ‘compute_20’, ‘sm_20’, and ‘sm_21’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
mkdir -p ../../bin/x86_64/linux/release
cp deviceQuery ../../bin/x86_64/linux/release
root@sun:/usr/local/cuda-8.0/samples/1_Utilities/deviceQuery# ./deviceQuery
./deviceQuery Starting…

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: “Ge GTX 1060 6GB”
   CUDA Driver Version / Runtime Version          9.0 / 8.0
   CUDA Capability Major/Minor version number:    6.1
   Total amount of global memory:                 6070 MBytes (6364463104 bytes)
   (10) Multiprocessors, (128) CUDA Cores/MP:     1280 CUDA Cores
   GPU Max Clock rate:                            1759 MHz (1.76 GHz)
   Memory Clock rate:                             4004 Mhz
   Memory Bus Width:                              192-bit
   L2 Cache Size:                                 1572864 bytes
   Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
   Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
   Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
   Total amount of constant memory:               65536 bytes
   Total amount of shared memory per block:       49152 bytes
   Total number of registers available per block: 65536
   Warp size:                                     32
   Maximum number of threads per multiprocessor:  2048
   Maximum number of threads per block:           1024
   Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
   Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
   Maximum memory pitch:                          2147483647 bytes
   Texture alignment:                             512 bytes
   Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
   Run time limit on kernels:                     Yes
   Integrated GPU sharing Host Memory:            No
   Support host page-locked memory mapping:       Yes
   Alignment requirement for Surfaces:            Yes
   Device has ECC support:                        Disabled
   Device supports Unified Addressing (UVA):      Yes
   Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
   Compute Mode:
      < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GTX 1060 6GB
Result = PASS

export CMAKE_CXX_FLAGS=-std=c++11

apt-get install liblapacke-dev checkinstall
apt-get install libavresample-dev
apt-get install libgphoto2
apt-get install libgphoto2-dev
apt-get install libdc1394-22
apt-get install libdc1394-22-dev
apt-get install liblapacke-dev checkinstall
apt-get install libxine2-dev

     -D CMAKE_INSTALL_PREFIX=/usr/local \
     -D OPENCV_EXTRA_MODULES_PATH=/home/dcml/opencv_build/opencv_contrib-3.3.1/modules \
     -D WITH_TBB=ON \
     -D WITH_CUDA=ON \
     -D CUDA_FAST_MATH=1 \
     -D WITH_CUBLAS=1 \

Building and running Python demo of
Simple Vehicle Counting
Vehicle Detection, Tracking and Counting

1. Install Boost library for Python
sudo apt-get install libboost-python-dev

2. Clone the repo
mkdir work
cd work
git clone –recursive

3. Apply Patch
cd simple_vehicle_counting
patch -p1 <fix.diff
git diff

4. Build
cd build
mkdir python
cp -r ../python/* python

5. Run demo

diff –git a/CMakeLists.txt b/CMakeLists.txt
index c205e27..5a5fd9b 100644
— a/CMakeLists.txt
+++ b/CMakeLists.txt

      # add some standard warnings
–    ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas)
+    ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas -fPIC)

     # -ansi does not compile with sjn module

Install OpenCV-Python with FFMPEG to Anaconda

I have summarized my now fully working solution OpenCV-Python – How to install OpenCV-Python package to Anaconda (Windows). Nevertheless I’ve

To use OpenCV fully with Anaconda (and Spyder IDE), we need to:

  1. Download the OpenCV package from the official OpenCV site
  2. Copy and paste the cv2.pyd to the Anaconda site-packages directory.
  3. Set user environmental variables so that Anaconda knows where to find the FFMPEG utility.
  4. Do some testing to confirm OpenCV and FFMPEG are now working.


Install Anaconda

Anaconda is essentially a nicely packaged Python IDE that is shipped with tons of useful packages, such as NumPy, Pandas, IPython Notebook, etc. It seems to be recommended everywhere in the scientific community. Check out Anaconda to get it installed.

Install OpenCV-Python to Anaconda

Cautious Note: I originally tried out installing the opencv package, as suggested. That method however does not include the FFMPEG codec – i.e. you may be able to use OpenCV but you won’t be able to process videos.

The following instruction works for me is inspired by this OpenCV YouTube video. So far I have got it working on both my Desktop and Laptop. Both 64-bit machines and Windows 8.1.

Download OpenCV Package

Firstly, go to the official OpenCV site to download the complete OpenCV package. Pick a version you like (2.x or 3.x). I am on Python 2.x and OpenCV 3.x – mainly because this is how the OpenCV-Python Tutorials are setup/based on.

In my case, I’ve extracted the package (essentially a folder) straight to my C drive. (C:\opencv).

Copy and Paste the cv2.pyd file

The Anaconda Site-packages directory (e.g. C:\Users\Johnny\Anaconda\Lib\site-packages in my case) contains the Python packages that you may import. Our goal is to copy and paste the cv2.pyd file to this directory (so that we can use the import cv2 in our Python codes.).

To do this, copy the cv2.pyd file…

From this OpenCV directory (the beginning part might be slightly different on your machine):

# Python 2.7 and 32-bit machine: 

# Python 2.7 and 64-bit machine: 

To this Anaconda directory (the beginning part might be slightly different on your machine):


After performing this step we shall now be able to use import cv2 in Python code. BUT, we still need to do a little bit more work to get FFMPEG (video codec) to work (to enable us to do things like processing videos.)

Set Enviromental Variables

Right-click on “My Computer” (or “This PC” on Windows 8.1) -> left-click Properties -> left-click “Advanced” tab -> left-click “Environment Variables…” button.

Add a new User Variable to point to the OpenCV (either x86 for 32-bit system or x64 for 64-bit system.) I am currently on a 64-bit machine.

| 32-bit or 64 bit machine? | Variable     | Value                                |
| 32-bit                    | `OPENCV_DIR` | `C:\opencv\build\x86\vc12`           |
| 64-bit                    | `OPENCV_DIR` | `C:\opencv\build\x64\vc12`           |

Append %OPENCV_DIR%\bin to the User Variable PATH.

For example, my PATH user variable looks like this…





This is it we are done! FFMPEG is ready to be used!

Test to confirm

We need to test whether we can now do these in Anaconda (via Spyder IDE):

  • Import OpenCV package
  • Use the FFMPEG utility (to read/write/process videos)
Test 1: Can we import OpenCV?

To confrim that Anaconda is now able to import the OpenCV-Python package (namely, cv2), issue these in the IPython Console:

import cv2
print cv2.__version__

If the package cv2 is imported ok with no errors, and the cv2 version is printed out, then we are all good! Here is a snapshot:


Test 2: Can we Use the FFMPEG codec?

Place a sample input_video.mp4 video file in a directory. We want to test whether we can:

  • read this .mp4 video file, and
  • write out a new video file (can be .avi or .mp4 etc.)

To do this we need to have a test python code, call it Place it in the same directory as the sample input_video.mp4 file.

This is what may look like (I’ve listed out both newer and older version codes here – do let us know which one works / not work for you!):

(Newer verison…)

import cv2
cap = cv2.VideoCapture("input_video.mp4")
print cap.isOpened()   # True = read video successfully. False - fail to read video.

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter("output_video.avi", fourcc, 20.0, (640, 360))
print out.isOpened()  # True = write out video successfully. False - fail to write out video.


(or the older version…)

import cv2
print cv2.isOpened()   # True = read video successfully. False - fail to read video.

fourcc =*'XVID')
out = cv2.VideoWriter("output_video.avi",fourcc, 20.0, (640,360))
print out.isOpened()  # True = write out video successfully. False - fail to write out video.


This test is VERY IMPORTANT. If you’d like to process video files, you’d need to ensure that Anaconda / Spyder IDE can use the FFMPEG (video codec). It took me days to have got it working. But I hope it would take you much less time! 🙂

Note: one more very important tip when using the Anaconda Spyder IDE. Make sure you check the Current Working Directory (CWD)!!!


To use OpenCV fully with Anaconda (and Spyder IDE), we need to:

  1. Download the OpenCV package from the official OpenCV site
  2. Copy and paste the cv2.pyd to the Anaconda site-packages directory.
  3. Set user environmental variables so that Anaconda knows where to find the FFMPEG utility.
  4. Do some testing to confirm OpenCV and FFMPEG are now working.

Good luck!

NASA’s 10 rules for developing safety-critical code

1: Restrict all code to very simple control flow constructs. Do not use GOTO statements, setjmp or longjmp constructs, or direct or indirect recursion.

2: All loops must have a fixed upper bound. It must be trivially possible for a checking tool to statically prove that a preset upper bound on the number of iterations of a loop cannot be exceeded. If the loop-bound cannot be proven statically, the rule is considered violated.

3: Do not use dynamic memory allocation after initialization.

4: No function should be longer than what can be printed on a single sheet of paper (in a standard reference format with one line per statement and one line per declaration.) Typically, this means no more than about 60 lines of code per function.

5: The assertion density of the code should average a minimum of two assertions per function. Assertions must always be side effect-free and should be defined as Boolean tests.

6: Data objects must be declared at the smallest possible level of scope.

7: Each calling function must check non-void function return values, and the validity of parameters must be checked inside each function.

8: Preprocessor use must be limited to the inclusion of header files and simple macro definitions. Token pasting, variable argument lists (ellipses), and recursive macro calls are not allowed.

9: The use of pointers should be restricted. Specifically, no more than one level of dereferencing is allowed. Pointer dereference operations may not be hidden in macro definitions or inside typedef declarations. Function pointers are not permitted.

10: All code must be compiled, from the first day of development, with all compiler warnings enabled at the compiler’s most pedantic setting. All code must compile with these setting without any warnings. All code must be checked daily with at least one—but preferably more than one—state-of-the-art static source code analyzer, and should pass the analyses with zero warnings.