/* * Class: org_imgsdk_core_NativeImageSdk * Method: setOutputPath * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_imgsdk_core_NativeImageSdk_setOutputPath (JNIEnv *env, jobject thiz, jlong ptr, jstring jpath) { LOG_ENTRY; SdkEnv* sdk = (SdkEnv *)((intptr_t)ptr); if (NULL == sdk) { LogE("NULL pointer exception\n"); return; } if (NULL == jpath) { LogE("NULL pointer exception\n"); return; } char *path = jstring2string(env, jpath); if (NULL == path) { LogE("output path is NULL\n"); return; } Log("output path:%s\n", path); setOutputImagePath(sdk, path); LOG_EXIT; }
/* * Console application entry * Usage: * imgsdk input output * Notice: * 1. input & onput support *.jpg or *.png * 2. support input and output image type are not same * 3. vert.shdr & frag.shdr must be prepared */ int main(int argc, char **argv) { if (3 != argc) { Log("Usage:\n"); Log(" %s input output\n", argv[0]); return -1; } SdkEnv *env = newDefaultSdkEnv(); if (NULL == env) { LogE("Failed get SdkEnv instance\n"); } setInputImagePath (env, argv[1]); setOutputImagePath (env, argv[2]); sdkMain (env); setEffectCmd (env, "{\"effect\":\"Normal\"}"); onSdkDraw (env); Bitmap_t *img = (Bitmap_t *) env->userData.param; uint32_t begin_t = getCurrentTime(); glBindTexture(GL_TEXTURE, env->handle.texture2Idx); memset (img->base, 0, img->width * img->height * img->form); // copy pixels from GPU memory to CPU memory int x = 0; int y = 0; GLint fmt = GL_RGBA; if (IMAGE_JPG == env->userData.inputImageType) { fmt = GL_RGB; } glReadPixels(x, y, img->width, img->height, fmt, GL_UNSIGNED_BYTE, img->base); int errCode = glGetError (); if (GL_NO_ERROR != errCode ) { Log ("Failed read pixles, error code:0x%04x\n", errCode); } uint32_t finish_t = getCurrentTime(); LogD("Read pixel data cost %d ms\n", (finish_t - begin_t)); begin_t = getCurrentTime(); if (NULL != env->userData.outputPath) { if (saveImage (env->userData.outputPath, img) < 0) { LogE ("Failed saveImage\n"); } else { finish_t = getCurrentTime(); LogD("Save %s cost %d ms\n", env->userData.outputPath, (finish_t - begin_t)); } } freeSdkEnv(env); //onSdkDestroy(env); }
/***************************************************************************** * @brief : main 主函数 * @author : Zhangle * @date : 2014/9/8 10:25 * @version : ver 1.0 * @inparam : * @outparam : *****************************************************************************/ int main(){ string outputImagePath = ""; string outputTxtPath = ""; string inputImagePath = ""; // vector<string> files; // getFiles("F:/test",files); FeatureDetect *fd; cout<<"开始提取特征点"<<endl; fd = new FeatureDetect; // inputImagePath = "F:/test/TTC00405.TIF";//图片路径 /*提取特征点*/ outputImagePath = setOutputImagePath(inputImagePath, SIFT_FEATURE); //设置输出图像的路径 outputTxtPath = setOutputTxtPath(inputImagePath,SIFT_FEATURE); //设置输出txt的路径 fd->siftFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); //提取SIFT特征点 outputImagePath = setOutputImagePath(inputImagePath, SURF_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,SURF_FEATURE); fd->surfFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); //提取SURF特征点 outputImagePath = setOutputImagePath(inputImagePath, ORB_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,ORB_FEATURE); fd->orbFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); //提取ORB特征点 fd = new FeatureDetect; inputImagePath = "F:/test/TTC00406.TIF"; outputImagePath = setOutputImagePath(inputImagePath, SIFT_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,SIFT_FEATURE); fd->siftFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); outputImagePath = setOutputImagePath(inputImagePath, SURF_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,SURF_FEATURE); fd->surfFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); outputImagePath = setOutputImagePath(inputImagePath, ORB_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,ORB_FEATURE); fd->orbFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); fd = new FeatureDetect; inputImagePath = "F:/test/TTC00436.TIF"; outputImagePath = setOutputImagePath(inputImagePath, SIFT_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,SIFT_FEATURE); fd->siftFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); outputImagePath = setOutputImagePath(inputImagePath, SURF_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,SURF_FEATURE); fd->surfFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); outputImagePath = setOutputImagePath(inputImagePath, ORB_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,ORB_FEATURE); fd->orbFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); fd = new FeatureDetect; inputImagePath = "F:/test/TTC00601.TIF"; outputImagePath = setOutputImagePath(inputImagePath, SIFT_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,SIFT_FEATURE); fd->siftFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); outputImagePath = setOutputImagePath(inputImagePath, SURF_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,SURF_FEATURE); fd->surfFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); outputImagePath = setOutputImagePath(inputImagePath, ORB_FEATURE); outputTxtPath = setOutputTxtPath(inputImagePath,ORB_FEATURE); fd->orbFeatureDetect(inputImagePath, outputImagePath, outputTxtPath); cout<<"特征点提取结束.."<<endl; }