Skip to content

Instantly share code, notes, and snippets.

View bha159's full-sized avatar

Bharat Kumar bha159

View GitHub Profile
@bha159
bha159 / iris.py
Created February 5, 2018 01:58
A python program to test SVM classifier with linear kernel and test the accuracy.
#Importing modules
from sklearn import svm # To fit the svm classifier
from sklearn import model_selection
import numpy as np
import pandas
#Import iris data to model Svm classifier
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
dataset = pandas.read_csv(url, names=names)
@bha159
bha159 / video.py
Created February 5, 2018 00:38
A python program that generates two real video from webcam, one in RGB format and other Greyscale.
import cv2
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('Vid', frame)
cv2.imshow('Gray', gray)
@bha159
bha159 / wordCalculate.py
Created February 5, 2018 00:35
A python program to calculate occurence of a word in a text file.
word=input("Enter a word\n")
handle=open("my_data.txt")
data=handle.read().split(" ")
d=dict()
for i in data:
if i in d:
d[i]+=1
else:
d[i]=1
@bha159
bha159 / wordCalculate.cpp
Last active February 5, 2018 00:35
A c++ program to calculate occurence of a word in a text file.
#include<iostream.h>
#include<fstream.h>
#include<string.h>
using namespace std;
int main()
{
ifstream fin("my_data.txt"); //opening text file
int count=0;
@bha159
bha159 / LED_Blink.c
Created July 13, 2017 06:19
This code is for blinking a LED connected to D2 pin of PIC16F877A,MPLAB X is used as IDE and CCS compiler is used. A 20MHz external oscillator is used in circuit.
@bha159
bha159 / grapper.ino
Created May 22, 2017 06:41
Arduino code for a gesture controlled hand(made using servo motor and acclerometer).
#include<Servo.h>
const int numReadings = 10;
int readings[numReadings] = {0};
int index = 0;
int total = 0;
int average = 0;
const int xPin = A0;
const int epsilon = 5;
long sensorValue = 0;
@bha159
bha159 / calibration.ino
Created May 22, 2017 06:14
For calibrating a line follower bot, which uses three IR sensors.
int sensorPin[]={A0,A1,A2}; /*Array of analog pins for sensor*/
int totalpin=3; /*Total No. of pins*/
const int ledpin=9;
int sensorMin[]={1023,1023,1023}; /*Array to store minimum values*/
int sensorMax[]={0,0,0}; /*Array to store maximum values*/
float sensorAvg[]={0.0,0.0,0.0}; /*Array to store average values*/
void calib()
{
int i,l,temp;
@bha159
bha159 / README-Template.md
Created May 20, 2017 22:42 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@bha159
bha159 / lcd.c
Created May 12, 2017 06:59
Code for creating rolling out effect on 16X2 lcd used with atmega328
#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"
#define STRING_LENGTH 27
#define LCD_MAX 15
void main()
{
char array[STRING_LENGTH] = { "Namaste" };
@bha159
bha159 / color.m
Created May 10, 2017 18:30
MATLAB function for detecting different colours and can be used with in other projects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
% Author : Bharat Kumar %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Initialization
function varargout = Colors(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...