Skip to content

Instantly share code, notes, and snippets.

@nikhil9
nikhil9 / getHSV.java
Last active December 13, 2015 18:38
Get HSV color space values of image pixel on mouse hover using JavaCV.
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import com.googlecode.javacv.cpp.opencv_core.*;
import com.googlecode.javacv.cpp.opencv_highgui.*;
public class getHSV{
public static int x_co;
@nikhil9
nikhil9 / getRGB.java
Last active August 20, 2017 05:37
Get RGB color space values of image pixel on mouse hover using JavaCV.
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import com.googlecode.javacv.cpp.opencv_core.*;
import com.googlecode.javacv.cpp.opencv_highgui.*;
public class getRGB{
public static int x_co;
public static int y_co;
@nikhil9
nikhil9 / FaceDetection.java
Created November 16, 2012 14:47
Code for Face Detection in Javacv using haar classifier.
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_objdetect.*;
public class FaceDetection{
public static final String XML_FILE =
"resources/haarcascade_frontalface_default.xml";
@nikhil9
nikhil9 / OpencvCam.c
Created November 15, 2012 19:24
Camera Access using Opencv
#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace std;
char key;
int main()
{
cvNamedWindow("Camera_Output", 1); //Create window
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY); //Capture using any camera connected to your system
@nikhil9
nikhil9 / JavacvCam.java
Created November 7, 2012 16:02
Camera Access using Javacv
import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.FrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.*;
import com.googlecode.javacv.OpenCVFrameGrabber;
import static com.googlecode.javacv.cpp.opencv_core.cvFlip;
public class demo_video {
public static void main(String[] args) {
//Create canvas frame for displaying webcam.
CanvasFrame canvas = new CanvasFrame("Webcam");
@nikhil9
nikhil9 / LoadGrayScaleImage.c
Created November 1, 2012 18:48
Sample code to load GrayScale image using Opencv
#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace std;
char key;
int main()
{
IplImage* frame=cvLoadImage("img1.png",CV_LOAD_IMAGE_GRAYSCALE); //Load image in IplImage frame.
cvNamedWindow("window1", CV_WINDOW_AUTOSIZE); //Create window of name 'Window1'
@nikhil9
nikhil9 / LoadColorImage.c
Created November 1, 2012 18:46
Sample code to load color image using Opencv
#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace std;
char key;
int main()
{
IplImage* frame=cvLoadImage("img1.png",CV_LOAD_IMAGE_COLOR); //Load image in IplImage frame.
cvNamedWindow("window1", CV_WINDOW_AUTOSIZE); //Create window of name 'Window1'
@nikhil9
nikhil9 / Highgui_demo.c
Created October 31, 2012 16:59
Opencv test snippet
#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace std;
int main()
{
cvNamedWindow("Hello", 1);
cvWaitKey(0);
cvDestroyWindow("Hello");
@nikhil9
nikhil9 / HoughCircle.java
Created October 31, 2012 16:52
Hough Circle detection in Javacv
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
public class circleDetection{
public static void main(String[] args){
IplImage src = cvLoadImage("img2.png");
IplImage gray = cvCreateImage(cvGetSize(src), 8, 1);
cvCvtColor(src, gray, CV_BGR2GRAY);
@nikhil9
nikhil9 / demo_video.java
Created October 31, 2012 15:58
Demo code for import and display video using Javacv
import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.FrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.*;
import com.googlecode.javacv.OpenCVFrameGrabber;
public class demo_video {
public static void main(String[] args) {
//Create canvas frame for displaying video.
CanvasFrame canvas = new CanvasFrame("VideoCanvas");