Skip to content

Instantly share code, notes, and snippets.

@abhinavjain241
abhinavjain241 / searchscript.sh
Created September 9, 2014 19:18
Google Search Script
#Google Search Script
#!/bin/sh
if [ "$3" = "" ]
{if [ "$2" = "v" ]
then
google-chrome http://www.google.com/search?q="$1 -inurl:(htm|html|php|pls|txt) intitle:index.of “last modified” (mkv|mp4|avi)"
elif [ "$2" = "m" ]
then
google-chrome http://www.google.com/search?q="$1 -inurl:(htm|html|php|pls|txt) intitle:index.of “last modified” (mp3|wma|aac|flac)"
fi}
@abhinavjain241
abhinavjain241 / MergeSortedList1.c
Created October 18, 2014 09:00
Merging of Sorted Lists ( Sparse Polynomial Addition) - 1
#include <stdio.h>
main()
{
int i,j,k,m,n,p,a[20],b[20],c[30];
printf("Give size of first list:");
scanf("%d",&n);
printf("Give elements of first list:");
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
@abhinavjain241
abhinavjain241 / SparsePolynomialAddition.c
Created October 18, 2014 09:02
Merging of Sorted Lists ( Sparse Polynomial Addition) - 2
#include <stdio.h>
main()
{
int i,j,k,m,n,x,a[20],b[20],p[30],q[30],c[30],r[30];
printf("Give size of first list:");
scanf("%d",&n);
printf("Give elements of first list:");
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
@abhinavjain241
abhinavjain241 / merge0.c
Created October 18, 2014 10:18
Merging of Sorted Lists ( Sparse Polynomial Addition) - 1 - Using Pointers - Destructive Method
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node *next;
}
node;
node* construct()
@abhinavjain241
abhinavjain241 / testopencv.cpp
Created October 28, 2014 17:32
Testing OpenCV installation
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
VideoCapture cap(0); // open the video camera no. 0
if (!cap.isOpened()) // if not success, exit program
@abhinavjain241
abhinavjain241 / genimage.cpp
Created December 1, 2014 07:56
Generate Striped Image
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image(200,300,CV_8UC3,Scalar(0,0,255));
@abhinavjain241
abhinavjain241 / compile.sh
Created December 1, 2014 09:45
Compile OpenCV C/C++
#!/bin/bash
echo "compiling $1"
if [[ $1 == *.c ]]
then
gcc -ggdb `pkg-config --cflags opencv` -o `basename $1 .c` $1 `pkg-config --libs opencv`;
elif [[ $1 == *.cpp ]]
then
g++ -ggdb `pkg-config --cflags opencv` -o `basename $1 .cpp` $1 `pkg-config --libs opencv`;
else
echo "Please compile only .c or .cpp files"
@abhinavjain241
abhinavjain241 / image_read.cpp
Created December 2, 2014 23:00
Read an Image - OpenCV
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image;
@abhinavjain241
abhinavjain241 / rgb_to_binary.cpp
Created December 2, 2014 23:15
RGB to Binary Image - OpenCV
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
//Define Threshold here
#define THRESH 127
using namespace std;
using namespace cv;
@abhinavjain241
abhinavjain241 / rgb_to_grayscale.cpp
Created December 2, 2014 23:26
RGB to Grayscale Image - OpenCV
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
//Define ratios for Blue , Green , Red respectively
#define A 0.1140
#define B 0.5870
#define C 0.2989
//These are nearly perfect values of ratios for conversion of RGB to Grayscale.
//However, you may use any other value of these ratios, just make sure that the resultant lies between 0 and 255