Reputation: 1146
i have started working on opencv on android platform. I wanted to change the hue of image, not the whole just the sub part of it. So how we do that
Change full image to hsv
then select that specific part (Matrix)
Or
I have also try some code using second method i am not succeed yet. So i want some good examples or some guidance how to acheive that.
Upvotes: 0
Views: 935
Reputation: 14053
You can use OpenCV camera preview example from sample folder
Try below code
//Global variable
private Mat src;
Mat hsv = null;
private CameraBridgeViewBase mOpenCvCameraView;
List<Mat> hsv_channel= new ArrayList<Mat>();
---------------------------------------
----------------------------------------
// Initialize Mat here
public void onCameraViewStarted(int width, int height) {
src = new Mat(height, width, CvType.CV_8UC4);
hsv = new Mat(height, width, CvType.CV_8UC4);
}
-----------------------------------------
---------------------------------------
//Process Mat here
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
src = inputFrame.rgba();
Imgproc.cvtColor(src, hsv,Imgproc.COLOR_BGR2HSV );
Core.split(hsv, hsv_channel);
Imgproc.equalizeHist(hsv_channel.get(0), hsv_channel.get(0)); //Get hue channel and perform hsitogram equlization
Core.merge(hsv_channel, hsv);
Imgproc.cvtColor(hsv, src,Imgproc.COLOR_HSV2BGR );
return src;
}
Upvotes: 1