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 - next...so 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);
System.out.println(image.nSize());
if (image != null) {
cvSmooth(image, image, CV_BLUR, 3);
cvSaveImage("smoothed_" + filename, image);
cvReleaseImage(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>>>>
   
   </code>
</pre>

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 .apk-.dex-.jar-.java

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 !!!

Java- extract / unzip a zip file - working code example

How to Extract / unzip a zip file in Java - complete source code example .
import java.io.*;
import java.util.zip.*;

public class UnzipTest {
    public static void unzipFile(File f) throws ZipException, IOException {

        ZipInputStream zin = new ZipInputStream(new FileInputStream(f));
        System.out.println(f.getAbsoluteFile());

        String workingDir = f.getPath() + File.separator + "unziped";

        byte buffer[] = new byte[4096];
        int bytesRead;

Java: using recursion to read a folder and its content in tree format sub-folders/files in tree format

Java CODE: Using recursion to read a folder and its content - sub-folders/files in tree format.

public class TreeTest {
      public static void main(String[] args) {
            showDir(1, new File("D:\\test"));
      }

      static void showDir(int indent, File file) {
            for (int i = 0; i < indent; i++)
                  System.out.print(' ');
            System.out.println(file.getName());
            if (file.isDirectory()) {
                  File[] files = file.listFiles();
                  for (int i = 0; i < files.length; i++)
                        showDir(indent + 4, files[i]);
            }
      }
}

Java : Generate JTree from XML dynamically - code example

In this post, i am going to describe how to generate JTree in swing according to an XML document dynamically.


Used XML File : catalog.xml