2014-05-21 07:27:48 -0600
| commented answer | How to show image above your face Detect? Alright then... Can you please give me code how to Display an image at my eyes detecting... I want to display glasses at my eyes detecting point. . . Rect eyearea_right = new Rect(r.x +r.width/16,(int)(r.y + (r.height/4.5)),(r.width - 2*r.width/16)/2,(int)( r.height/3.0));
Rect eyearea_left = new Rect(r.x +r.width/16 +(r.width - 2*r.width/16)/2,(int)(r.y + (r.height/4.5)),(r.width - 2*r.width/16)/2,(int)( r.height/3.0));
Core.rectangle(mRgba,eyearea_left.tl(),eyearea_left.br() , new Scalar(255,0, 0, 255), 2);
Core.rectangle(mRgba,eyearea_right.tl(),eyearea_right.br() , new Scalar(255, 0, 0, 255), 2);
this is the code How I detect eyes. . . |
2014-05-21 01:11:46 -0600
| commented answer | How to show image above your face Detect? Rect[] facesArray = faces.toArray(); for (int i = 0; i < facesArray.length; i++){
Rect r = facesArray[i];
Core.rectangle(mGray, r.tl(), r.br(), new Scalar(0, 255, 0, 255), 3);
Core.rectangle(mRgba, r.tl(), r.br(), new Scalar(0, 255, 0, 255), 3);
I am using this method for face rectangle.... and I want to show an image above this.... |
2014-05-20 06:51:24 -0600
| asked a question | How to show image above your face Detect? Hello All, I want to show a Cap image above my face detect surface which I just detect. I searched almost all the google but couldn't find any code. Please share code which gamble me to this problem. |
2014-05-19 08:30:57 -0600
| asked a question | How to Display an image during On-line processing Hello OpenCV, Once again I need your help :) I want to show an image upper side of my face detect. I search it every where but could not find any way . . . My code is here bellow plz help how I can display. . . class FdView extends SampleCvViewBase {
private static final String TAG = "Sample::FdView";
private Mat mRgba;
private Mat mGray; private Mat mZoomCorner;
private Mat mZoomWindow;
private Mat mZoomWindow2;
private Mat mResult;
private Mat teplateR;
private Mat teplateL;
private File mCascadeFile;
private CascadeClassifier mJavaDetector;
private CascadeClassifier mCascadeER;
private CascadeClassifier mCascadeEL;
private DetectionBasedTracker mNativeDetector;
private static final Scalar FACE_RECT_COLOR = new Scalar(0, 255, 0, 255);
public static final int JAVA_DETECTOR = 0;
public static final int NATIVE_DETECTOR = 1;
private static final int TM_SQDIFF = 0;
private static final int TM_SQDIFF_NORMED = 1;
private static final int TM_CCOEFF = 2;
private static final int TM_CCOEFF_NORMED = 3;
private static final int TM_CCORR = 4;
private static final int TM_CCORR_NORMED = 5;
private int mDetectorType = JAVA_DETECTOR;
private float mRelativeFaceSize = 0;
private int mAbsoluteFaceSize = 0;
private int learn_frames = 0;
private double match_value;
// private Rect eyearea = new Rect(); public void setMinFaceSize(float faceSize)
{
mRelativeFaceSize = faceSize;
mAbsoluteFaceSize = 0;
}
public void setDetectorType(int type)
{
if (mDetectorType != type)
{
mDetectorType = type;
if (type == NATIVE_DETECTOR)
{
Log.i(TAG, "Detection Based Tracker enabled");
mNativeDetector.start();
}
else
{
Log.i(TAG, "Cascade detector enabled");
mNativeDetector.stop();
}
}
}
public void resetLearFramesCount()
{
learn_frames = 0;
}
public FdView(Context context) {
super(context);
try {
InputStream is = context.getResources().openRawResource(R.raw.lbpcascade_frontalface);
File cascadeDir = context.getDir("cascade", Context.MODE_PRIVATE);
mCascadeFile = new File(cascadeDir, "lbpcascade_frontalface.xml");
FileOutputStream os = new FileOutputStream(mCascadeFile);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = is.read(buffer)) != -1) {
os.write(buffer, 0, bytesRead);
}
is.close();
os.close();
// --------------------------------- load left eye classificator -----------------------------------
InputStream iser = context.getResources().openRawResource(R.raw.haarcascade_lefteye_2splits);
File cascadeDirER = context.getDir("cascadeER", Context.MODE_PRIVATE);
File cascadeFileER = new File(cascadeDirER, "haarcascade_eye_right.xml");
FileOutputStream oser = new FileOutputStream(cascadeFileER);
byte[] bufferER = new byte[4096];
int bytesReadER;
while ((bytesReadER = iser.read(bufferER)) != -1) {
oser.write(bufferER, 0, bytesReadER);
}
iser.close();
oser.close();
//----------------------------------------------------------------------------------------------------
// --------------------------------- load right eye classificator ------------------------------------
InputStream isel = context.getResources().openRawResource(R.raw.haarcascade_lefteye_2splits);
File cascadeDirEL = context.getDir("cascadeEL", Context.MODE_PRIVATE);
File cascadeFileEL = new File(cascadeDirEL, "haarcascade_eye_left.xml");
FileOutputStream osel = new FileOutputStream(cascadeFileEL);
byte[] bufferEL = new byte[4096];
int bytesReadEL;
while ((bytesReadEL = isel.read(bufferEL)) != -1) {
osel.write(bufferEL, 0, bytesReadEL);
}
isel.close();
osel.close();
// ------------------------------------------------------------------------------------------------------
mJavaDetector = new CascadeClassifier(mCascadeFile.getAbsolutePath());
mCascadeER = new CascadeClassifier(cascadeFileER.getAbsolutePath());
mCascadeEL = new CascadeClassifier(cascadeFileER.getAbsolutePath());
if (mJavaDetector.empty()|| mCascadeER.empty() || mCascadeEL.empty()) {
Log.e(TAG, "Failed to load cascade classifier");
mJavaDetector = null;
mCascadeER=null;
mCascadeEL=null;
} else
Log.i(TAG, "Loaded cascade classifier from " + mCascadeFile.getAbsolutePath());
mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0);
cascadeDir.delete();
cascadeFileER.delete();
cascadeDirER.delete();
cascadeFileEL.delete();
cascadeDirEL.delete();
} catch (IOException e) {
e.printStackTrace();
Log.e(TAG, "Failed to load cascade. Exception thrown: " + e);
}
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
synchronized (this) {
// initialize Mats before usage
mGray = new Mat();
mRgba = new Mat();
//images = new Mat();
}
super.surfaceCreated(holder);
}
@Override
protected Bitmap processFrame(VideoCapture capture) {
capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
capture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME);
if (mAbsoluteFaceSize ... (more) |
2014-05-19 08:26:12 -0600
| commented answer | How to include Opencv path? Ok I got rid from this problem. . . I simply put my OpenCV SDK to the same folder where my ndk was. . . Now i open this same path on window and copy the whole address and paste here. . .Now it is working fine. . . thanks for your nice consideration . . . |
2014-05-15 09:02:05 -0600
| asked a question | How to resolve ExceptionsINinitializer Error Hello OpenCV, Apologize I know I am gonna asking this question twice but I was not familiar with it earlier. Anyway when I compile the code I got error in my activity at File. . .
private File mCascadeFile;
This is how i initialize File object. . .Bellow is final code. . . public FdView(Context context) {
super(context); try {
InputStream is = context.getResources().openRawResource(R.raw.lbpcascade_frontalface);
File cascadeDir = context.getDir("cascade", Context.MODE_PRIVATE);
mCascadeFile = new File(cascadeDir, "lbpcascade_frontalface.xml");
FileOutputStream os = new FileOutputStream(mCascadeFile);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = is.read(buffer)) != -1) {
os.write(buffer, 0, bytesRead);
}
is.close();
os.close();
// --------------------------------- load left eye classificator -----------------------------------
InputStream iser = context.getResources().openRawResource(R.raw.haarcascade_lefteye_2splits);
File cascadeDirER = context.getDir("cascadeER", Context.MODE_PRIVATE);
File cascadeFileER = new File(cascadeDirER, "haarcascade_eye_right.xml");
FileOutputStream oser = new FileOutputStream(cascadeFileER);
byte[] bufferER = new byte[4096];
int bytesReadER;
while ((bytesReadER = iser.read(bufferER)) != -1) {
oser.write(bufferER, 0, bytesReadER);
}
iser.close();
oser.close();
//----------------------------------------------------------------------------------------------------
// --------------------------------- load right eye classificator ------------------------------------
InputStream isel = context.getResources().openRawResource(R.raw.haarcascade_lefteye_2splits);
File cascadeDirEL = context.getDir("cascadeEL", Context.MODE_PRIVATE);
File cascadeFileEL = new File(cascadeDirEL, "haarcascade_eye_left.xml");
FileOutputStream osel = new FileOutputStream(cascadeFileEL);
byte[] bufferEL = new byte[4096];
int bytesReadEL;
while ((bytesReadEL = isel.read(bufferEL)) != -1) {
osel.write(bufferEL, 0, bytesReadEL);
}
isel.close();
osel.close();
// ------------------------------------------------------------------------------------------------------
mJavaDetector = new CascadeClassifier(mCascadeFile.getAbsolutePath());
mCascadeER = new CascadeClassifier(cascadeFileER.getAbsolutePath());
mCascadeEL = new CascadeClassifier(cascadeFileER.getAbsolutePath());
if (mJavaDetector.empty()|| mCascadeER.empty() || mCascadeEL.empty()) {
Log.e(TAG, "Failed to load cascade classifier");
mJavaDetector = null;
mCascadeER=null;
mCascadeEL=null;
} else
Log.i(TAG, "Loaded cascade classifier from " + mCascadeFile.getAbsolutePath());
mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0);
cascadeDir.delete();
cascadeFileER.delete();
cascadeDirER.delete();
cascadeFileEL.delete();
cascadeDirEL.delete();
and I have exception on the following line. . . mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0);
|
2014-05-15 08:45:04 -0600
| commented question | java.lang.exceptionininitializererror I have exception in the followng line mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0); |
2014-05-15 08:18:11 -0600
| commented question | java.lang.exceptionininitializererror I just got the problem but I am fail how to resolve it? I need your help because this is mine first project on OpenCV. . . I send you my code please give me the way to PM you. . . . |
2014-05-15 08:08:09 -0600
| commented question | java.lang.exceptionininitializererror Ok Berak I have Identify the error The error is in another class. . . How I can send you a PM apologize I am new in this forum |
2014-05-15 05:15:10 -0600
| commented question | java.lang.exceptionininitializererror If I unComment that line then I got error Find library return null. . . why is it so? |
2014-05-14 08:51:10 -0600
| commented question | java.lang.exceptionininitializererror Ok check I have edited my post and send my main Activity |
2014-05-14 08:50:24 -0600
| received badge | ● Editor
(source)
|
2014-05-14 08:30:34 -0600
| commented question | java.lang.exceptionininitializererror By the way I shared a link in my question I am following all that coding.... |
2014-05-14 08:29:37 -0600
| commented question | java.lang.exceptionininitializererror Actully I have many classis. . . .which class me have to share with you.... |
2014-05-14 07:00:18 -0600
| asked a question | java.lang.exceptionininitializererror Hi foolks,
I am new here in this form and new in OpenCV. I am making a project of eyes detection followed by http://romanhosek.cz/android-eye-detection-and-tracking-with-opencv/ tutorial. But at the end I got logcat wrror java.lang.exceptionininitializererror Please help.... Thanks in Advance. . . private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS: {
Log.i(TAG, "OpenCV loaded successfully"); // Load native libs after OpenCV initialization
// System.loadLibrary("detection_based_tracker");
// Create and set View
mView = new FdView(mAppContext);
mView.setDetectorType(mDetectorType);
mView.setMinFaceSize(0.2f);
VerticalSeekBar VerticalseekBar = new VerticalSeekBar(
getApplicationContext());
VerticalseekBar.setMax(5);
VerticalseekBar.setPadding(20, 20, 20, 20);
RelativeLayout.LayoutParams vsek = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, 400);
vsek.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
VerticalseekBar.setId(1);
VerticalseekBar
.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar,
int progress, boolean fromUser) {
method = progress;
switch (method) {
case 0:
matching_method.setText("TM_SQDIFF");
break;
case 1:
matching_method.setText("TM_SQDIFF_NORMED");
break;
case 2:
matching_method.setText("TM_CCOEFF");
break;
case 3:
matching_method.setText("TM_CCOEFF_NORMED");
break;
case 4:
matching_method.setText("TM_CCORR");
break;
case 5:
matching_method.setText("TM_CCORR_NORMED");
break;
}
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
matching_method = new TextView(getApplicationContext());
matching_method.setText("TM_SQDIFF");
matching_method.setTextColor(Color.YELLOW);
RelativeLayout.LayoutParams matching_method_param = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
matching_method_param
.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
matching_method_param.addRule(RelativeLayout.BELOW,
VerticalseekBar.getId());
Button btn = new Button(getApplicationContext());
btn.setText("Create template");
RelativeLayout.LayoutParams btnp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
btnp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
btn.setId(2);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mView.resetLearFramesCount();
}
});
RelativeLayout frameLayout = new RelativeLayout(
getApplicationContext());
frameLayout.addView(mView, 0);
frameLayout.addView(btn, btnp);
frameLayout.addView(VerticalseekBar, vsek);
frameLayout.addView(matching_method, matching_method_param);
setContentView(frameLayout);
// Check native OpenCV camera
if (!mView.openCamera()) {
AlertDialog ad = new AlertDialog.Builder(mAppContext)
.create();
ad.setCancelable(false); // This blocks the 'BACK' button
ad.setMessage("Fatal error: can't open camera!");
ad.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
ad.show();
}
}
break;
default: {
super.onManagerConnected(status);
}
break;
}
}
};
private int mDetectorType = 0;
private String[] mDetectorName;
public FdActivity() {
Log.i(TAG, "Instantiated new " + this.getClass());
mDetectorName = new String[2];
mDetectorName[FdView.JAVA_DETECTOR] = "Java";
mDetectorName[FdView.NATIVE_DETECTOR] = "Native (tracking)";
}
@Override
protected void onPause() {
Log.i(TAG, "onPause");
super.onPause();
if (mView != null)
mView.releaseCamera();
}
@Override
protected void onResume() {
Log.i(TAG, "onResume");
super.onResume();
if (mView != null && !mView.openCamera()) {
AlertDialog ad = new AlertDialog.Builder(this).create();
ad.setCancelable(false); // This blocks the 'BACK' button
ad.setMessage("Fatal error: can't open camera!");
ad.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
ad.show();
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "onCreate");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Log.i(TAG, "Trying to load OpenCV library");
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this,
mOpenCVCallBack)) {
Log.e(TAG, "Cannot connect to OpenCV Manager");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
Log.i(TAG, "onCreateOptionsMenu");
mItemFace50 = menu.add("Face size 50%");
mItemFace40 = menu.add("Face ... (more) |
2014-05-14 03:59:43 -0600
| asked a question | How to include Opencv path?
I am Afraid about this error how to resolve this? I have searched almost all the Internet but couldn't find the solution. . . . |