资源简介
深入理解OpenCV:实用计算机视觉项目解析 - 源代码
代码片段和文件信息
/*****************************************************************************
* Cartoonifier for Android.
******************************************************************************
* by Shervin Emami 5th Dec 2012 (shervin.emami@gmail.com)
* http://www.shervinemami.info/
******************************************************************************
* Ch1 of the book “Mastering OpenCV with Practical Computer Vision Projects“
* Copyright Packt Publishing 2012.
* http://www.packtpub.com/cool-projects-with-opencv/book
*****************************************************************************/
#include
#include
#include
#include
#include “cartoon.h“
#include “ImageUtils.h“ // Handy functions for debugging OpenCV images by Shervin Emami.
using namespace std;
using namespace cv;
extern “C“ {
// Just show the plain camera image without modifying it.
JNIEXPORT void JNICALL Java_com_Cartoonifier_CartoonifierView_ShowPreview(JNIEnv* env jobject
jint width jint height jbyteArray yuv jintArray bgra)
{
// Get native access to the given Java arrays.
jbyte* _yuv = env->GetByteArrayElements(yuv 0);
jint* _bgra = env->GetIntArrayElements(bgra 0);
// Prepare a cv::Mat that points to the YUV420sp data.
Mat myuv(height + height/2 width CV_8UC1 (uchar *)_yuv);
// Prepare a cv::Mat that points to the BGRA output data.
Mat mbgra(height width CV_8UC4 (uchar *)_bgra);
// Convert the color format from the camera‘s
// NV21 “YUV420sp“ format to an Android BGRA color image.
cvtColor(myuv mbgra CV_YUV420sp2BGRA);
// OpenCV can now access/modify the BGRA image if we want ...
// Release the native lock we placed on the Java arrays.
env->ReleaseIntArrayElements(bgra _bgra 0);
env->ReleaseByteArrayElements(yuv _yuv 0);
}
DECLARE_TIMING(CartoonifyImage);
// Modify the camera image using the Cartoonifier filter.
JNIEXPORT void JNICALL Java_com_Cartoonifier_CartoonifierView_CartoonifyImage(JNIEnv* env jobject
jint width jint height jbyteArray yuv jintArray bgra
jboolean sketchMode jboolean alienMode jboolean evilMode jboolean debugMode)
{
START_TIMING(CartoonifyImage);
// Get native access to the given Java arrays.
jbyte* _yuv = env->GetByteArrayElements(yuv 0);
jint* _bgra = env->GetIntArrayElements(bgra 0);
// Input color format (from camera):
// “myuv“ is the color image in the camera‘s native NV21 YUV 420 “semi-planar“ format which means
// the first part of the array is the grayscale pixel array followed by a quarter-sized pixel
// array that is the U & V color channels interleaved. So if we just want to access a grayscale
// image we can get it directly from the 1st part of a YUV420sp semi-planar image without any
// conversions. But if we want a color image (eg: BGRA color format that i
- 上一篇:十四届华为杯优秀论文.rar
- 下一篇:AMT630A芯片完整资料和开发工具软件
相关资源
- 学习OpenCV(中文版)pdf文档+源码
- 学习opencv 中文版及源码
- opencv-3.3.1 for vs2013
- computer organization and design 5th edition
- The Art of Computer Programming 1-4计算机程序
- An Invitation to 3-D Vision From Images to Geo
- Computer Organization and Design 5th 计算机组
- keil uVision4C51内含注册机
- OpenCV3.2编译文件
- QtOpencvImageGUI
- OpenCV实现多目三维重建
- opencv2.4.13lib_x86_x64_vs2013
- 形状匹配find_scaled_shape_model
- Real-time Rendering 3rd(彩色版)
- OpenCV 3.3_x86_minGW_world
- Opencv-stitcher基本原理参考文献
- opencv调用海康威视摄像头源代码内大
- 配合单文档调用opencv的代码
- opencv SVM图分类训练图片和测试图片
- QT+opencv的图像处理
- HOG+Adaboost级联分类器训练代码
- VS+QT+Opencv可视化编程
- 最全的OpenCV源代码
- 基于Opencv的红外运动目标识别与跟踪
- NI_Vision_Builder_AI入门教程 ( ni 视觉概
- mingw编译的opencv库
- The art of Computer Systems Performance
- 基于ORB算法的特征提取和匹配(VS20
- 基于SIFT算法的特征提取(VS2015+OpenC
- 深入理解计算机系统(英文版)(第
评论
共有 条评论