Oct 19, 2017

How to free up disk space on Windows

If you have a small disk size and have to open free space frequently on Windows then this post is for you.

You deleted some files, emptied recycle bin, moved some files to another drive but still you need free space. Because Windows is living, getting updates, creating cache files also you install new applications. First we will give a chance to Windows for disk cleanup then we will try to find more files to delete.

  1. Windows Cleanup

  2. Right click to C:\ drive and select Properties. You will see Disk Cleanup  button in General tab.
     

    This will give you some space. You can see many unnecessary items here like temporary files, Windows Update files etc. If you are not happy with that space then continue.

  3. Find more files

  4. WinDirStat is a utility that shows size statistics about your files and folders in your drive. With this tool you can see which folders and files have the most size. I love this tool because its graphical interface shows file types in colors, sizes as blocks. You can select a big block and see which file it is.  For example I ordered folders and files by size. In my computer the Installer folder is very huge. It occupies nearly 30% size in Windows folder. When you explore in Installer folder you will see many setup and patch files. We can't know which file is used by the system or necessary by looking their names. File names are like "1a88ba.msp".

  5. Analyze Installer folder

  6. You shouldn't delete files from Installer folder because uninstall process will search for installation files in this folder. Alternatively you can backup this folder content in somewhere else or zip the folder. This may also can create workload because you need to put right file again to start uninstall process.

    Patch Cleaner is an application that searchs Installer folder for unnecesarry files -namely orphaned files. 

    You can see necessary files with their explanation.
     

    Orphaned file list shows files that are not connected to any application.



    You can move orphaned files to another drive like a USB disk by pressing Move button.

  7. Continue to investigate files with WinDirStat

Oct 16, 2017

Install opencv package in Python

Opencv is very popular library on all platforms. This article explains how to install opencv package for Python. This will give you a general idea about installing any library in Python environment.

In code samples you will see cv2 library is imported.
import cv2
If you run sample code without installing opencv you will get following error.
Traceback (most recent call last):
  File "pythonface.py", line 2, in
    import cv2
ImportError: No module named cv2

Installing python package from online repository is very easy in python. You can search for a package in PyPI (Python Package Index) interface.

Type opencv to search box in pypi webpage (https://pypi.python.org/pypi)

This will give you a long list which contains your keyword.
List cropped for blog post.

Finding right package may be hard in this list. You can find package names from original sources of specific libraries.

If you click "opencv-python 3.3.0.10" from the list (https://pypi.python.org/pypi/opencv-python/3.3.0.10) you will see installation and usage guide.

On docs.opencv.org you can see library name as opencv-python:
OpenCV-Python is the Python API for OpenCV, combining the best qualities of the OpenCV C++ API and the Python language.
Use following command to install opencv library to your computer from PyPI.
pip install opencv-python
Now you are ready to use opencv functions.

If you can't find opencv-python package in your installation you can download source codes and run commands according to your environment. This link will give you an idea about sequence of this work.

Aug 15, 2017

Split video into frames

You can split video into frames with AForge libraries.

Add reference following libraries:
  • AForge.Video
  • AForge.Video.FFMPEG

// create instance of video reader
VideoFileReader reader = new VideoFileReader();
// open video file
reader.Open("C:\\test.mp4");
long framecount = reader.FrameCount; 

// read video frames 
for (int i = 0; i < framecount; i++)
{
 Bitmap videoFrame = reader.ReadVideoFrame();
 
 videoFrame.Save(Environment.CurrentDirectory + "\\" + i + ".bmp");

 // dispose the frame when it is no longer required
 videoFrame.Dispose();
}
reader.Close();

Quickwatch reader object
ReadVideoFrame: Read next video frame of the currently opened video file.