image created but fail opencv
Posted: 06 January 2012 06:24 PM   [ Ignore ]
Rank
Joined  2012-01-03
Total Posts:  1
New Member

hii,, i am new in here, i am chan from ind, iam newbie on opencv & android, but i have project for nudity detection, i choose opencv, i have xml cascade file for porn image, it’s work good on my ubuntu, but i wanna to implement on my android device. so i use jni for cross compile on my device.

i am try on my device with some line code but fail..
i have porn.xml cascade for nudity image on /sdcard/porn.xml and i
have porn image c.jpg on /sdcard/c.jpg.
source image.cpp on jni folder like this:

#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>

extern "C"{
        JNIEXPORT void JNICALL Java_com_test_opencv_Opencvtest_setimage
  
(JNIEnv *envjobject obj{

        IplImage
imgIn cvLoadImage("/sdcard/c.jpg");
        
int scale =1;
                if(!
imgIn){
                }else{

                IplImage
imgGray cvCreateImage(cvGetSize(imgIn),IPL_DEPTH_8U,
1);
                
cvCvtColor(imgIn,imgGray,CV_BGR2GRAY);
                const 
charresult2 "/sdcard/c_2.jpg";
                
cvSaveImage(result2,imgGray);

                
IplImageimgporn =  cvCreateImagecvSize(imgIn->width/scale,imgIn-
>
height/scale), 8);

                
CvMemStoragestorage cvCreateMemStorage(0);
                
CvHaarClassifierCascadecascade =
(
CvHaarClassifierCascade*)cvLoad"/sdcard/porn.xml" );

                
cvClearMemStoragestorage );
                
CvSeqobjects cvHaarDetectObjectsimgporncascadestorage,
1.1,2CV_HAAR_DO_CANNY_PRUNING,cvSize4040 ));

                
CvRectr;
                for( 
int i 0< (objects objects->total ); i++ ){
                         
static CvScalar colors[] =
                                
{
                                        {{0
,0,255}},
                                        
{{0,128,255}},
                                        
{{0,255,255}},
                                        
{{0,255,0}},
                                        
{{255,128,0}},
                                        
{{255,255,0}},
                                        
{{255,0,0}},
                                        
{{255,0,255}}
                                }
;
            
CvRect= (CvRect*)cvGetSeqElemobjects);
            
CvPoint center;
            
int radius;
            
center.cvRound((r->r->width*0.5)*scale);
            
center.cvRound((r->r->height*0.5)*scale);
            
radius cvRound((r->width r->height)*0.25*scale);
            
cvCircleimgporncenterradiuscolors[i%8]CV_FILLED,
8);
                        
}
                        
const charresult1 "/sdcard/c_1.jpg";
                        
cvSaveImage(result1,imgporn);

                        
cvReleaseImage(&imgIn);
                        
cvReleaseImage(&imgGray);
                        
cvReleaseImage(&imgporn);
                
}
  }

}

the activity like this:

package com.test.opencv;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class 
Opencvtest extends Activity {
    
/** Called when the activity is first created. */
        
public native void setimage();
        
static{
                System
.loadLibrary("imagefea");
        
}
    
@Override
    
public void onCreate(Bundle savedInstanceState{
        super
.onCreate(savedInstanceState);
        
TextView tv = new TextView(this);
        
long StartTime System.currentTimeMillis();
        
setimage();
        
long ProcessTime System.currentTimeMillis() - StartTime;
        
tv.setText(String.valueOf(ProcessTime));
        
setContentView(tv);
    
}

}

screenshoot:

before running app
running app
after running app

c_1.jpg created but no image..

please help me sir… & sorry for my English ,,thanks

Profile
 
 
Posted: 12 December 2013 10:20 PM   [ Ignore ]   [ # 1 ]
Rank
Joined  2013-12-02
Total Posts:  20
New Member

Here is a image creating tool form a third party which is devoted to prorgamming image prorgams, following is the method for creating image to file in the bmp, jpeg, png, gif or tiff file format.

Public Shared Sub New(Width As Integer, Height As Integer, PixelFormat As PixelFormat, BackColor As Color)

Profile