Summer Targets

I have now completed two semesters at Georgia Tech and feel that I am now a changed person. I’ve been wanting to post an update for a long time but procrastination got the best of me.

I now maintain a code repository at http://bitbucket.org/schidam. I use bitbucket since it allows me to keep certain repositories private. Some of my projects are up there.

My plan for the summer is to post more code from some of my projects at GT, and maybe attempt implementing some advanced algorithms.

Stay tuned for updates 🙂

Cheers!

Sethu

Angle Calculation in OpenCV

Last month, I wrote a small piece of code to calculate the angle between two specified points. The result returned will be in degrees with respect to the positive X axis. The function is as below:

// This function calculates the angle of the line from A to B with respect to the positive X-axis in degrees
int angle(Point2f A, Point2f B) {
	int val = (B.y-A.y)/(B.x-A.x); // calculate slope between the two points
	val = val - pow(val,3)/3 + pow(val,5)/5; // find arc tan of the slope using taylor series approximation
	val = ((int)(val*180/3.14)) % 360; // Convert the angle in radians to degrees
	if(B.x < A.x) val+=180;
	if(val < 0) val = 360 + val;
	return val;
}

Cheers!

Sethu

Do comment for any questions regarding this.

Taking Interval Snapshots and Saving them to Disk with OpenCV

Hey guys!,
I’ve started working with OpenCV for a research project here at Georgia Tech. This was part of my initial tasks in week 1 of the project.

The code is quite self explanatory, do post questions if any.

!!! MAKE SURE YOU ADD THE PROPER STREAM ADDRESS IN THE CODE !!!

#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <opencv2\opencv.hpp>
#include <iostream>
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <string>
#include <Windows.h>

int main( int argc, const char** argv ) {
	// Capture Object
	VideoCapture vcap;

	string address = ” “; //Enter stream address here
	string location;
	time_t start;
	int interval = 0, j=0;
	Mat image;

	// Parameters to Save Image
	vector compression_params; //vector that stores the compression parameters of the image
	compression_params.push_back(CV_IMWRITE_JPEG_QUALITY); //specify the compression technique
	compression_params.push_back(98); //specify the compression quality

	cout << “Please wait until the camera opens…” <<endl;
	if ( !vcap.open(address) ) {
		cout << “\nUnable to access camera.” << endl;
		return -1;
	}
	cout << interval;
	cout << location;
	start = time(NULL);
	while(1) {
		vcap.read(image);
		if (interval != 0 && ((time(NULL)-start)%interval == 0) && start != time(NULL)) {
		cout << ++j <<endl;
		imshow(“Inteval Snap”, image);
		waitKey(30);
		start = time(NULL);
		string op_file = location + to_string(j) + “.jpg”;
		cout << op_file <<endl;
		if(!imwrite(op_file,image,compression_params)) {
			return -2;
		}
		waitKey(30);
		}
	}
	vcap.release();
}

Cheers!
Sethu Chidambaram

Experiments with Light and a Convex Lens

Image Inversion 1 Image Inversion 2 Image Inversion Set UP Image Inversion and Reflection

Well, physics in the real world is cool!

I recently found this magnifying glass when clearing out my desk and remembered doing this when I was a kid. Just found time to actually document this 🙂

High School Physics at Play: When an object is placed at infinity, the image is formed at the principal focus of the lens. The image formed is small, real and inverted.

Cheers!

Sethu Chidambaram