JavaCV - Color based thresholding in image using OpenCV

JavaCV - Red color based thresholding (RGB-A space) in image using OpenCV : Full working java source code 

Note that the order of colors is BGR-A not RGB-A. 
Read it more from
//static imports
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
//non-static imports
import com.googlecode.javacv.cpp.opencv_core.CvScalar;
import com.googlecode.javacv.cpp.opencv_core.IplImage;

JavaCV capture-save-flip-show live camera

NOTE: Updated code with configuration and example is available here:


JavaCV:  Capture/save/flip image and show live image on CanvasFrame from camera

import static com.googlecode.javacv.cpp.opencv_core.cvFlip;
import static com.googlecode.javacv.cpp.opencv_highgui.cvSaveImage; import com.googlecode.javacv.CanvasFrame; import com.googlecode.javacv.FrameGrabber; import com.googlecode.javacv.VideoInputFrameGrabber; import com.googlecode.javacv.cpp.opencv_core.IplImage; public class GrabberShow implements Runnable { //final int INTERVAL=1000;///you may use interval IplImage image; CanvasFrame canvas = new CanvasFrame("Web Cam"); public GrabberShow() { canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); } @Override public void run() { FrameGrabber grabber = new VideoInputFrameGrabber(0); // 1 for next camera int i=0; try { grabber.start(); IplImage img; while (true) { img = grabber.grab(); if (img != null) { cvFlip(img, img, 1);// l-r = 90_degrees_steps_anti_clockwise cvSaveImage((i++)+"-aa.jpg", img); // show image on window canvas.showImage(img); } //Thread.sleep(INTERVAL); } } catch (Exception e) { } }

public static void main(String[] args) { GrabberShow gs = new GrabberShow(); Thread th = new Thread(gs); th.start(); } }

Java Code : Capture Image from webcam using JavaCV

Java Code for capturing image from webcam- uses JavaCV (java wrapper for OpenCV) library
Working CODE:
import com.googlecode.javacv.OpenCVFrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.IplImage; import static com.googlecode.javacv.cpp.opencv_highgui.*; public class CaptureImage { private static void captureFrame() { // 0-default camera, 1 - on final OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0); try { grabber.start(); IplImage img = grabber.grab(); if (img != null) { cvSaveImage("capture.jpg", img); } } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { captureFrame(); } }

JavaCV- Image load, smooth and save

Static Imports:
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;

Image Smoothing:
public static void smoothSave(String filename) throws Exception {
IplImage image = cvLoadImage(filename);
if (image != null) {
cvSmooth(image, image, CV_BLUR, 3);
cvSaveImage("smoothed_" + filename, image);

OpenCV-JavaCV : eclipse project configuration windows 7

NOTE: A Easier and Simpler version of the installation step is available !!  Check the latest ( Jan , 2017) article.


Eclipse (windows 7) project setup for JNA wrapper of OpenCV : JavaCV - getting started.

OpenCV (Open Source Computer Vision Library) is library of programming functions for real time computer vision.  JavaCV provides wrappers to commonly used libraries for OpenCV and few others.

Download the Essentials :

CSS Format Source Code in blog articles - blogger, wordpress

CSS script to format source code in blog posting in blogger, wordpress... articles.

The working css script : Source Code Formatter CSS Script
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; 
            color: #000000; background-color: #eee;
            font-size: 12px; border: 1px dashed #999999;
            line-height: 14px; padding: 5px; 
            overflow: auto; width: 100%">
   <code style="color:#000000;word-wrap:normal;">
        <<<<YOUR CODE HERE>>>>

HTML/XML Tag Parsing using Regex in Java

This time, I am going to show how to parse the html tags like : 
xx <tag a ="b" c=  'd' e=f> yy </tag> zz

(Did you noticed the single,double and no-quote attribute values and spaces ? It is important to consider all these variations.)

Android Reverse Engineering - decompile

Reverse engineering of android java app using apktool, dex2jar, jd-gui to convert .apk file to .java.
By reverse engineering of android app (.apk file) we can get following :

NTC Nepal Telecom gprs setting via sms - free

Activating GPRS in NTC (for both prepaid and postpaid service) FREE

  1. Type vgprs (in your Message Box) & Send to 1400 for GPRS Activation. :) 

To get GPRS configuration for your mobile set : FREE

  1. Send SMS to 1404 - you need to enter following different code according to your mobile set and send it to 1404
    • Type gprs (nokia, lg, motorolla, indian etc) (in your Msg Box)
    • Type sagprs (samsung mobiles) (in your Message Box) 
    • Type segprs (sony ericsson mobiles)
    • Type chgprs (chinese mobiles)
  2. After few minutes you will get setting and save it using pin code 1234.
  3. You might need to restart your set. Enjoy Browsing !!!