Merged android-experimental branch back to trunk.
This commit is contained in:
54
android/android-opencv/jni/include/Calibration.h
Normal file
54
android/android-opencv/jni/include/Calibration.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Processor.h
|
||||
*
|
||||
* Created on: Jun 13, 2010
|
||||
* Author: ethan
|
||||
*/
|
||||
|
||||
#ifndef PROCESSOR_H_
|
||||
#define PROCESSOR_H_
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/features2d/features2d.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "image_pool.h"
|
||||
|
||||
#define DETECT_FAST 0
|
||||
#define DETECT_STAR 1
|
||||
#define DETECT_SURF 2
|
||||
|
||||
class Calibration
|
||||
{
|
||||
public:
|
||||
|
||||
Calibration();
|
||||
virtual ~Calibration();
|
||||
|
||||
bool detectAndDrawChessboard(int idx, image_pool* pool);
|
||||
|
||||
void resetChess();
|
||||
|
||||
int getNumberDetectedChessboards();
|
||||
|
||||
void calibrate(const char* filename);
|
||||
|
||||
void drawText(int idx, image_pool* pool, const char* text);
|
||||
|
||||
cv::Size patternsize;
|
||||
private:
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
|
||||
std::vector<std::vector<cv::Point2f> > imagepoints;
|
||||
|
||||
cv::Mat K;
|
||||
cv::Mat distortion;
|
||||
cv::Size imgsize;
|
||||
|
||||
};
|
||||
|
||||
#endif /* PROCESSOR_H_ */
|
19
android/android-opencv/jni/include/android_logger.h
Normal file
19
android/android-opencv/jni/include/android_logger.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#define LOG_TAG "libopencv"
|
||||
#if ANDROID
|
||||
#include <android/log.h>
|
||||
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
|
||||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
|
||||
#else
|
||||
#include <cstdio>
|
||||
#define LOGI(...) printf("info:");printf("%s:",LOG_TAG); fprintf(stdout,__VA_ARGS__);printf("\n");
|
||||
#define LOGE(...) printf("error:");printf("%s:",LOG_TAG); fprintf(stderr,__VA_ARGS__);printf("\n");
|
||||
#endif
|
||||
|
||||
#ifndef LOGI_STREAM
|
||||
#define LOGI_STREAM(x) {std::stringstream ss; ss << x; LOGI("%s",ss.str().c_str());}
|
||||
#endif
|
||||
#define LOGE_STREAM(x) {std::stringstream ss; ss << x; LOGE("%s",ss.str().c_str());}
|
48
android/android-opencv/jni/include/glcamera.h
Normal file
48
android/android-opencv/jni/include/glcamera.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef GLCAMERA_H_
|
||||
#define GLCAMERA_H_
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#include "image_pool.h"
|
||||
|
||||
class glcamera
|
||||
{
|
||||
public:
|
||||
|
||||
glcamera();
|
||||
~glcamera();
|
||||
void init(int width, int height);
|
||||
void step();
|
||||
|
||||
void drawMatToGL(int idx, image_pool* pool);
|
||||
void drawMatToGL(const cv::Mat& img);
|
||||
void setTextureImage(const cv::Mat& img);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
GLuint createSimpleTexture2D(GLuint _textureid, GLubyte* pixels, int width, int height, int channels);
|
||||
GLuint loadShader(GLenum shaderType, const char* pSource);
|
||||
GLuint
|
||||
createProgram(const char* pVertexSource, const char* pFragmentSource);
|
||||
bool setupGraphics(int w, int h);
|
||||
void renderFrame();
|
||||
cv::Mat nimg;
|
||||
bool newimage;
|
||||
GLuint textureID;
|
||||
|
||||
GLuint gProgram;
|
||||
GLuint gvPositionHandle;
|
||||
|
||||
GLuint gvTexCoordHandle;
|
||||
GLuint gvSamplerHandle;
|
||||
float img_w, img_h;
|
||||
};
|
||||
#endif
|
51
android/android-opencv/jni/include/image_pool.h
Normal file
51
android/android-opencv/jni/include/image_pool.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef IMAGE_POOL_H_ANDROID_KDJFKJ
|
||||
#define IMAGE_POOL_H_ANDROID_KDJFKJ
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <map>
|
||||
|
||||
|
||||
|
||||
class image_pool
|
||||
{
|
||||
|
||||
public:
|
||||
image_pool();
|
||||
~image_pool();
|
||||
cv::Mat getImage(int i);
|
||||
cv::Mat getGrey(int i);
|
||||
cv::Mat getYUV(int i);
|
||||
|
||||
int getCount()
|
||||
{
|
||||
return imagesmap.size();
|
||||
}
|
||||
|
||||
/** Adds a mat at the given index - will not do a deep copy, just images[i] = mat
|
||||
*
|
||||
*/
|
||||
void addImage(int i, cv::Mat mat);
|
||||
|
||||
/** this function stores the given matrix in the the yuvImagesMap. Also,
|
||||
* after this call getGrey will work, as the grey image is just the top
|
||||
* half of the YUV mat.
|
||||
*
|
||||
* \param i index to store yuv image at
|
||||
* \param mat the yuv matrix to store
|
||||
*/
|
||||
void addYUVMat(int i, cv::Mat mat);
|
||||
|
||||
void convertYUVtoColor(int i, cv::Mat& out);
|
||||
|
||||
// int addYUV(uchar* buffer, int size, int width, int height, bool grey,int idx);
|
||||
//
|
||||
// void getBitmap(int * outintarray, int size, int idx);
|
||||
private:
|
||||
std::map<int, cv::Mat> imagesmap;
|
||||
std::map<int, cv::Mat> yuvImagesMap;
|
||||
|
||||
};
|
||||
|
||||
void copyMatToBuffer(char* buffer, const cv::Mat& mat);
|
||||
void copyBufferToMat(cv::Mat& mat, const char* buffer);
|
||||
void RGB2BGR(const cv::Mat& in, cv::Mat& out);
|
||||
#endif
|
147
android/android-opencv/jni/include/yuv2rgb.h
Normal file
147
android/android-opencv/jni/include/yuv2rgb.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/* YUV-> RGB conversion code.
|
||||
*
|
||||
* Copyright (C) 2008-9 Robin Watts (robin@wss.co.uk) for Pinknoise
|
||||
* Productions Ltd.
|
||||
*
|
||||
* Licensed under the GNU GPL. If you need it under another license, contact
|
||||
* me and ask.
|
||||
*
|
||||
* This program is free software ; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation ; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program ; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef YUV2RGB_H
|
||||
|
||||
#define YUV2RGB_H
|
||||
|
||||
/* Define these to something appropriate in your build */
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
extern const uint32_t yuv2rgb565_table[];
|
||||
extern const uint32_t yuv2bgr565_table[];
|
||||
|
||||
void yuv420_2_rgb565(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
void yuv422_2_rgb565(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
void yuv444_2_rgb565(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
void yuv420_2_rgb888(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
void yuv422_2_rgb888(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
void yuv444_2_rgb888(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
void yuv420_2_rgb8888(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
void yuv422_2_rgb8888(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
void yuv444_2_rgb8888(uint8_t *dst_ptr,
|
||||
const uint8_t *y_ptr,
|
||||
const uint8_t *u_ptr,
|
||||
const uint8_t *v_ptr,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t y_span,
|
||||
int32_t uv_span,
|
||||
int32_t dst_span,
|
||||
const uint32_t *tables,
|
||||
int32_t dither);
|
||||
|
||||
|
||||
#endif /* YUV2RGB_H */
|
17
android/android-opencv/jni/include/yuv420sp2rgb.h
Normal file
17
android/android-opencv/jni/include/yuv420sp2rgb.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef YUV420SP2RGB_H
|
||||
#define YUV420SP2RGB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void color_convert_common(
|
||||
const unsigned char *pY, const unsigned char *pUV,
|
||||
int width, int height, unsigned char *buffer,
|
||||
int grey);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user