2013-11-13 15:07:35 -0600 | asked a question | mixChannels() giving exception in opencv android I am writing function to find rectangles in Mat. But i am getting exception at mixChannels()function. My code is as follow. Can some one check and tell me what could be wrong in it ?I would also like to know how i can implement gray = gray0 >= (l+1)*255/N; in java or android ? private void findSqaures(Mat sourceImage){ Vector<point> sqares; Mat pyr,timing ,gry =new Mat(); pyr=new Mat(sourceImage.size(),CvType.CV_8U); timing=new Mat(sourceImage.size(),CvType.CV_8U); int thresh = 50, N = 11; List<mat> grayO=new ArrayList<mat>(); List<mat> timing1=new ArrayList<mat>(); Imgproc.pyrDown(sourceImage, pyr,new Size(sourceImage.cols()/2.0, sourceImage.rows()/2)); Imgproc.pyrUp(pyr, timing,sourceImage.size()); // Vector<point> contours=new Vector<point>(); timing1.add(0,pyr); grayO.add(0,timing); // grayO.add(0,timing); for(int c=0;c<3;c++){ int ch[]={1,0}; // Core.mixChannels(src, dst, fromTo) for(int i=0;i<n;i++){ mat="" output="grayO.get(0);" if(i="=0){</p"> // output = output >= (i+1)*255/N; } // sourceImage=gry; contours=new ArrayList<matofpoint>(); Imgproc.findContours(gry, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); MatOfPoint2f approxCurve = new MatOfPoint2f(); mDrawnContours.clear(); Log.i(TAG, "::findSqaures:" + "contours.size():"+contours.size()); for(int j=0;i<contours.size();j++){ matofpoint="" tempcontour="contours.get(i);" matofpoint2f="" newmat="new" matofpoint2f(="" tempcontour.toarray()="" );="" int="" contoursize="(int)tempContour.total();</p"> // if( approx.size() == 4 && fabs(contourArea(cv::Mat(approx))) > 1000 && cv::isContourConvex(cv::Mat(approx))) { if(points.toArray().length==4 && (Math.abs(approxCurve.total())>1000) && Imgproc.isContourConvex(points)){ double maxCosine=0; int k; for( k=2;k<5;k++){ double cosine=Math.abs(angle(points.toArray()[k%4], points.toArray()[k-2], points.toArray()[k-1])); if(maxCosine>cosine){ maxCosine=cosine; } } Log.i(TAG, "::findSqaures:" + "maxCosine:"+maxCosine); if(maxCosine<0.3){ DrawnContours drawnContours=new DrawnContours(); drawnContours.setIndex(k); mDrawnContours.add(drawnContours); // Core.mixChannels(src, dst, fromTo) The exception is CvException [org.opencv.core.CvException: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/matrix.cpp:3210: error: (-215) A.size == arrays[i0]->size in function void cv::NAryMatIterator::init(const cv::Mat, cv::Mat, uchar, int)* |
2013-11-12 09:53:00 -0600 | asked a question | not able tot detect phisycal door or other big rectangle in open cv android I wrote code to detect rectangles in open cv. And i am able to detect few object but i am not able to detect physical door or big rectangle. Please check my code and correct me if i am wrong somewhere . Mat output= getGray(inputFrame.rgba(),inputFrame.rgba()); Imgproc.medianBlur(output, output, 5); Imgproc.erode(output, output, new Mat()); Imgproc.dilate(output, output, new Mat()); Mat edges = new Mat(); Imgproc.Canny(output, output, 5, 50); // Vector<matofpoint> vector=new Vector<matofpoint>(); // Imgproc.findContours(output, points, output, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); contours = new ArrayList<matofpoint>(); Mat hierarchy = new Mat(); contours.clear(); Imgproc.findContours(output, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); MatOfPoint2f approxCurve = new MatOfPoint2f(); rgbImage=inputFrame.rgba(); mDrawnContours.clear();
for(int i=0;i< contours.size();i++){ MatOfPoint tempContour=contours.get(i); MatOfPoint2f newMat = new MatOfPoint2f( tempContour.toArray() ); int contourSize = (int)tempContour.total(); Imgproc.approxPolyDP(newMat, approxCurve, contourSize*0.15, true); MatOfPoint points=new MatOfPoint(approxCurve.toArray()); return rgbImage |
2013-11-07 10:28:25 -0600 | commented question | Resizing an image HI i am facing same problem in android. how did you sort out your problem ? |
2013-11-07 06:19:01 -0600 | asked a question | resize() fail when i pass newSize parameter Hello, In android i am trying to scale my mat using following code. But i get exception or assertion faiiled. Mat destMat = new Mat(); Size newSize=new Size(output.width()/6.0f, output.height()/6.0f); Imgproc.resize(output, destMat, newSize, 0, 0, Imgproc.INTER_CUBIC); when it try to execute resize method i get following exception. My code is in onCameraFrame(). MatToBitmap catched cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean) |