Ask Your Question

HawkWang's profile - activity

2020-09-22 09:25:40 -0600 received badge  Nice Question (source)
2017-10-14 21:52:38 -0600 received badge  Famous Question (source)
2016-03-22 17:16:23 -0600 received badge  Notable Question (source)
2016-01-28 07:41:15 -0600 received badge  Notable Question (source)
2015-02-26 09:47:32 -0600 received badge  Popular Question (source)
2014-07-29 05:01:40 -0600 received badge  Popular Question (source)
2012-08-21 00:06:00 -0600 asked a question How to directly process ROI of preview data and display the processed data on screen?

I am processing the frame data in onPreviewFrame() function. I would like to change the left-top 1/4 part of the preview data to gray while keep the other part as colorful image. Because I am a beginner of OpenCV I don't know what is the best method. So I use a workaround:

  1. change the data parameter of onPreviewFrame from yuv to rgb, then use matToBitmap() function to convert it to a bitmap.
  2. change the ROI data to a gray bitmap (COLOR_GRAY2RGBA, and then matToBitmap()).
  3. draw the gray bitmap onto the first bitmap I get
  4. draw the bitmap on canvas.

Although this method works, I still want to know whether there is a better method: can I directly process the ROI of original data and convert new whole data to a bitmap, and draw the bitmap on canvas. Is there any way I can do it?

2012-08-20 23:59:08 -0600 commented answer Is there cvSetImageROI function in OpenCV on Android?

OK Rui, I will do that

2012-08-20 07:43:20 -0600 commented answer Is there cvSetImageROI function in OpenCV on Android?

Yes, Rui. I agree with you. But because I am beginner of OpenCV I don't know what is the proper method. So I use a workaround: 1. change the data parameter of onPreviewFrame from yuv to rgb, then use matToBitmap() function to convert it to a bitmap. 2. change the ROI data to a gray bitmap (COLOR_GRAY2RGBA, and then matToBitmap()). 3. draw the gray bitmap onto the first bitmap I get 4. draw the bitmap on canvas. Although this new method works, I still want to know whether there is a better method: only process the ROI of original data and convert new data to a bitmap, and draw the bitmap on canvas. Do you have any idea?

2012-08-19 21:11:52 -0600 commented answer Is there cvSetImageROI function in OpenCV on Android?

I've just tried your method and it works. Thank you. But here comes an interesting question.

Suppose I am processing the preview data in onPreviewFrame, with a parameter "data" contains the preview data. Now I want to only change the left-top 1/4 of the preview image to gray while keep the other part of the image as colorful one. That means I have to set ROI to left-top 1/4 of the image and call cvtColor function. Previously, I tried: Imgproc.cvtColor(original_data, mRgba, Imgproc.COLOR_YUV420sp2RGB, 4);

Mat graySubmat = mRgba.submat(0,0,width/2,height/2);

Imgproc.cvtColor(graySubmat, mRgbaGray, Imgproc.COLOR_GRAY2RGBA, 4);

mRgbaGray.copyTo(graySubmat);

But exception happens to such code: error: (-215) scn == 1 && (dcn == 3 || dcn == 4) in function void cv::cvtColor

2012-08-19 21:09:16 -0600 commented answer Is there cvSetImageROI function in OpenCV on Android?

XCoder, I've just tried your method and it works. Thank you. But here comes an interesting question. Suppose I am processing the preview data in onPreviewFrame, with a parameter "data" contains the preview data. Now I want to only change the left-top 1/4 of the preview image to gray while keep the other part of the image as colorful one. That means I have to set ROI to left-top 1/4 of the image and call cvtColor function. Previously, I tried: Imgproc.cvtColor(original_data, mRgba, Imgproc.COLOR_YUV420sp2RGB, 4);

Mat graySubmat = croppMat(0,0,width/2,height/2); //Set ROI to left-top 1/4 image Mat mRgbaGray;

Imgproc.cvtColor(graySubmat, mRgbaGray, Imgproc.COLOR_GRAY2RGBA, 4);

mRgbaGray.copyTo(graySubmat);

But exception happens to such code. Idea?

2012-08-19 20:18:54 -0600 commented answer Is there cvSetImageROI function in OpenCV on Android?

Rui, thank you. I think this one works. I will try the method and post result here today.

2012-08-19 20:18:09 -0600 commented answer Is there cvSetImageROI function in OpenCV on Android?

Thank you XCoder, but I am not sure your method works or not because I don't know wether the croppMat function is a "copy" method or a "pointing" method. to set the ROI we should use "pointing" method. Anyway, I will try your method later and I will post a response here today.

2012-08-17 04:05:42 -0600 received badge  Student (source)
2012-08-17 00:23:30 -0600 asked a question Is there cvSetImageROI function in OpenCV on Android?

Hi, I can't find the cvSetImageROI like function in Android OpenCV 2.4.2 SDK. How can I set a ROI on android application? Thank you in advance.

2012-08-14 04:51:47 -0600 commented answer FisherFaceRecognizer in Python, segment fault.

[To Philipp] I have tested the fix by just repeating the steps I failed last time. And now it runs OK! No "Segment Fault" anymore. Again, thanks a lot!

2012-08-14 03:03:03 -0600 commented answer FisherFaceRecognizer in Python, segment fault.

[To Philipp] I am sorry that I left my computer for several days that I haven't check the fix. I will soon test your fix and thank you so much for help! And thank you for your spirit of open source. I will soon post my test result.

2012-08-02 00:20:44 -0600 commented answer FisherFaceRecognizer in Python, segment fault.

[To Philipp] Thank you so much for your detail answer. I've tried again but failed again. So here let me repeat my steps.

  1. I am using Ubuntu linux 11.04, 64bit version
  2. my python version is: python 2.7.1+
  3. I git cloned the latest opencv code, see below:

Hawk@mymachine:~/work/OpenCV/OpenCV-Current/opencv$ git remote -v

origin git://code.opencv.org/opencv.git (fetch)

origin git://code.opencv.org/opencv.git (push)

===

Hawk@mymachine:~/work/OpenCV/OpenCV-Current/opencv$ git branch

  • master

===

Hawk@mymachine:~/work/OpenCV/OpenCV-Current/opencv$ git pull

Already up-to-date.

===

Then I cmake and make and sudo make install.

Then run your script on AT&T face database, and I got "Segment Fault".

I don't know why, can you help?

2012-08-01 04:20:55 -0600 asked a question FisherFaceRecognizer in Python, segment fault.

Hi, I am writing a small python script to learn cv2.fisherFaceRecognizer in python, based on latest OpenCV source code. And I write the code based on the code of http://answers.opencv.org/question/253/broken-python-bindings-with/?answer=255#post-id-255, which is for eigenFaceRecognizer.

I just modified below code from eigenFaceRecognizer to fisherFaceRecognizer, then when I run the script it is crashed by segment fault.

model = cv2.createEigenFaceRecognizer()----> changed to cv2.createFisherFaceRecognizer()
model.train(np.asarray(X), np.asarray(y))

Is there anyone that met the same problem? Any solution?