Posts

Current Total CPU Usage in Dev-C++

Image
#include <windows.h> #include <stdio.h> //------------------------------------------------------------------------------------------------------------------ // Prototype(s)... //------------------------------------------------------------------------------------------------------------------ CHAR cpuusage(void); //----------------------------------------------------- typedef BOOL ( __stdcall * pfnGetSystemTimes)( LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime ); static pfnGetSystemTimes s_pfnGetSystemTimes = NULL; static HMODULE s_hKernel = NULL; //----------------------------------------------------- void GetSystemTimesAddress() {     if( s_hKernel == NULL ) {         s_hKernel = LoadLibrary( "Kernel32.dll" );         if( s_hKernel != NULL ) {             s_pfnGetSystemTimes = (pfnGetSystemTimes)GetProcAddress...

Install Visual C++ 2010 Express

Image
Visual C++ is one of the components of Visual Studio (others include Visual Web Developer for ASP.NET with C# or VB and etc.). Visual C++ 2010 Express is part of the Visual Studio 2010 Express family, a free set of tools that Windows developers at any level can use to create custom applications using basic and expert settings. Microsoft Visual C++ (often abbreviated as MSVC or VC++) is a commercial (free version available), integrated development environment (IDE) product from Microsoft for the C, C++, and C++/CLI programming languages. It features tools for developing and debugging C++ code, especially code written for the Microsoft Windows API, the DirectX API, and the Microsoft .NET Framework. Click this link for difference between C++ and (Microsoft) Visual C++ . You can get the software from here . It is a 3.16 MB file named vc_web.exe. [This is the only working source I could find when I googled for the setup, you may suggest any other sources if good enough!]

Dev-C++ Errors and Solutions

Image
Issue: [Error] 'ofstream' was not declared in this scope Problem code snippet: #include <iostream> #include <fstream> int main() {     ofstream myfile; // TO DO........     return 0; } Solution code snippet: #include <iostream> #include <fstream> using namespace std; int main() {     ofstream myfile; // TO DO........     return 0; }

50 Software Performance Analyzers (Profilers)

Image
What is Profiler? Most commonly, profiling information serves to aid program optimization. Profiling is achieved by instrumenting either the program source code or its binary executable form using a tool called a profiler (or code profiler). Reference: https://en.wikipedia.org/wiki/Profiling_%28computer_programming%29 Simply put, any tool or technique you use to analyze and optimize the performance can be called a profiler. How does Profilers work? Commonly used profilers simply examine the running program regularly to see what assembly instruction is currently being executed (the program counter) and which routines called the current function (the call stack). This kind of sampling profiler can work with standard binaries, but are more useful if you have debugging symbols to work out lines of code given addresses in the program.

K-Nearest Neighbour in Python with OpenCV 3.0

Image
Problem: K-Nearest Neighbour is a machine learning classification algorithm. In this program we are having 5 individual test data (Green colour) that we need to classify as either Red or Blue group member. Here we are using 51 (odd number) randomly generated training data that will either become Red or Blue group member, which will decide whether the test data will become Red or Blue group member. Here the length of k is 9 which indicated 9 nearest neighbours will decide fate of the test data. Code: import cv2 import numpy as np import matplotlib.pyplot as plt trainData = np.random.randint(0,100,(51,2)).astype(np.float32) responses = np.random.randint(0,2,(51,1)).astype(np.float32) red = trainData[responses.ravel()==0] plt.scatter(red[:,0],red[:,1],80,'r','^') blue = trainData[responses.ravel()==1] plt.scatter(blue[:,0],blue[:,1],80,'b','s')