Removed some debugging insertions.
Added test for face detector.
Allowed tests to write on sdcard.
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
-
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
</manifest>
\ No newline at end of file
import org.opencv.Mat;
import org.opencv.objdetect;
-import org.opencv.imgproc;
import org.opencv.highgui;
import org.opencv.core;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
import org.opencv.Rect;
import org.opencv.Size;
+import org.opencv.Scalar;
public class objdetectTest extends OpenCVTestCase {
public void testCascadeClassifierFaceDetector() {
- //objdetect.CascadeClassifier cc=new objdetect.CascadeClassifier("/mnt/sdcard/lbpcascade_frontalface.xml");
- objdetect.CascadeClassifier cc=new objdetect.CascadeClassifier("/mnt/sdcard/haarcascade_frontalface_alt2.xml");
+ objdetect.CascadeClassifier cc=new objdetect.CascadeClassifier("/mnt/sdcard/lbpcascade_frontalface.xml");
+ ///objdetect.CascadeClassifier cc=new objdetect.CascadeClassifier("/mnt/sdcard/haarcascade_frontalface_alt2.xml");
ArrayList<Rect> faces=new ArrayList<Rect>();
cc.detectMultiScale(shot002, faces, 1.1, 2, 2 /*TODO: CV_HAAR_SCALE_IMAGE*/, new Size(10,10));
OpenCVTestRunner.Log("faces.size="+faces.size());
+
+ Scalar color=new Scalar(0,255,0);
+ for(int i=0; i < faces.size(); i++) {
+ OpenCVTestRunner.Log("face["+i+"]="+faces.get(i).toString());
+ core.rectangle(shot002, faces.get(i).tl(), faces.get(i).br(), color);
+ }
+ OpenCVTestRunner.Log("before writing image");
+ boolean reswrite=highgui.imwrite("/mnt/sdcard/lbpcascade_frontalface_res.jpg", shot002);
+ OpenCVTestRunner.Log("after writing image, res="+reswrite);
+
}
if(! m) return 0;\r
if(! buff) return 0;\r
\r
+ count *= sizeof(T);//This change is required, checked TODO: recheck for non-continious case\r
int rest = ((m->rows - row) * m->cols - col) * m->channels() * sizeof(T);\r
if(count>rest) count = rest;\r
int res = count;\r
int num = (m->cols - col - 1) * m->channels() * sizeof(T); // 1st partial row\r
if(count<num) num = count;\r
uchar* data = m->ptr(row++, col);\r
- while(count>0){\r
+ while(count>0){//TODO: recheck this cycle for the case col!=0\r
memcpy(buff, data, num);\r
count -= num;\r
buff += num;\r
\r
void Mat_to_vector_Rect(Mat& mat, vector<Rect>& v_rect)\r
{\r
- LOGD("Mat_to_vector_Rect start, mat.cols=%d", mat.cols);\r
v_rect.clear();\r
\r
if(mat.type()!= CV_32SC4 || mat.rows!=1) {\r
Vec<int, 4> v=mat.at< Vec<int, 4> >(0, i);\r
v_rect.push_back( Rect(v[0], v[1], v[2], v[3]) );\r
}\r
- LOGD("Mat_to_vector_Rect end, vec.size=%d", (int)v_rect.size());\r
}\r
\r
void vector_Rect_to_Mat(vector<Rect>& v_rect, Mat& mat)\r
{\r
- LOGD("vector_Rect_to_Mat start, vec.size=%d", (int)v_rect.size());\r
mat.create(1, v_rect.size(), CV_32SC4);\r
for(size_t i=0; i<v_rect.size(); i++) {\r
mat.at< Vec<int, 4> >(0, i) = Vec<int, 4>(v_rect[i].x, v_rect[i].y, v_rect[i].width, v_rect[i].height);\r
}\r
- LOGD("vector_Rect_to_Mat end, mat.cols=%d", mat.cols);\r
}\r
\r
\r