Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image Filtering/Manipulation Using JavaCv(Java wrapper for OpenCV) in Android

I aim to apply filters(Gray-scale, Vintage, Contrast, Sharpen, Blur, Smooth etc) to iplImage of the JavaCv. In doing so, I have come across these functions/Classes : iplImage, CvMat, cvInRangeS,cvCvtColor,cvSmooth. I wish to seek some clarification on these. Following are my specific queries:

  1. iplImage cvMatrix Bitmap Conversion
  2. iplImage's Format HSV/RGB/BGR.....ARGB/XYZ/Bayer/LUV in reference to cvCvtColor
  3. cvSmooth various forms
  4. cvInRange Demonstration
  5. cvMat Usage
  6. Can I build my filters with these all
like image 454
Parth Kapoor Avatar asked Nov 01 '22 01:11

Parth Kapoor


1 Answers

I would like to share the knowledge that I have acquired while using JavaCv for Image and Video filtering.I have been successful in developing my filters (Gray-scale, Vintage, Contrast, Sharpen, Blur & Smooth) using JavaCv. I could easily do Image filtering with Bitmap Manipulation, but it was too slow to be used for Video Filtering.

These are some key points that I wish to highlight

  1. FFmpegFrameGrabber gives us a Frame object. This object has two parts: The iplImage and the Sound. Frame.image gives the iplImage and if Frame.image==null, then it is the Sound. Actually, the Frame object contains only iplImage or the sound at one particular instance of time.
  2. The iplImage received by Frame.image, has YCrCb format. So using cvColor would use the conversion parameter CV_YCrCb2RGB,CV_YCrCb2RGBA etc.
  3. Now talking about FFmpegFrameRecorder, one can easily record a iplImage using this class and generate the video calling the recorder.record(Ipl_Image). You can use frameGrabber.getImageWidth(), frameGrabber.getImageHeight(),frameGrabber.getAudioChannels() as the parameters to the constructor of FFmpegFrameRecorder, if you wish to use the FrameGrabber and the FrameRecorder as a Feedback implementation.
  4. To record the sound from FrameGrabber, it requires to check the Frame.image parameter at each iteration. If this is not null, then record the iplImage or if it is null record the Frame. Doing this will add both sound and iplImage to the recorded file.
  5. The iplImage and Bitmap can be easily inter-converted using the writeToBuffer and coppyFromBuffer functions. But the thing to keep in mind is that Bitmap has 4 channels associated with it, so the iplImage object should also be 4-Channeled.
  6. Finally about image filters, Following functions were sufficient to serve my needs:
    1. Smooth : cvSmooth(IplSrc,IplSrc,CV_GAUSSIAN,9,9,2,2);
    2. BLur : Blur=(int) (.05*IplSrc.width()); cvSmooth(IplSrc, IplSrc, CV_BLUR,Blur );
    3. Gray Scale : cvCvtColor
    4. Vintage : cvAddS
    5. Smooth : cvSmooth(IplSrc, IplSrc, CV_MEDIAN, 13);
    6. Contrast : cvInRangeS()
like image 149
Parth Kapoor Avatar answered Nov 14 '22 20:11

Parth Kapoor