Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bd948b3
Added automatically generated C bindings and raw Haskell bindings.
Mar 15, 2014
7a55cc6
Incorporating bindings-DSL fixes from Greg Hale.
Mar 15, 2014
c7d87b6
Some bug fix work, and I removed the copied hdr_parser.py source file…
Mar 15, 2014
dbbd715
More bug fixes -- the c wrappers now correctly build into libopencv_c…
Mar 15, 2014
cb47443
Cleaned up the CMakelists.txt file to automatically find added header…
Mar 15, 2014
c0167c7
Added static and dynamic lib output for wrapper to support complex li…
Mar 16, 2014
9f76f64
Added matrix construction with data pointer.
Mar 17, 2014
b958b59
Added new mat constructor to the hs bindings.
Mar 17, 2014
16229a1
Moving towards a pure API in the Haskell module with the understandin…
Mar 17, 2014
bcdbb89
added size.hpp and size.cpp files with new additions
Apr 4, 2014
088b4f8
Merge pull request #3 from W-Net-AI/master
Apr 4, 2014
3844f28
Switched point.c/hpp to macros for wrapping
Apr 5, 2014
eab94d3
Merge branch 'master' of github.com:arjuncomar/opencv_contrib
Apr 5, 2014
fe68f30
Added files for functions that need special casing.
Apr 13, 2014
5061f5d
Changed to a uniform naming scheme in Point.hsc
Apr 13, 2014
ebf57f3
added new file scalar.cpp
Apr 15, 2014
1a1a949
added cv_Mat_convertTo cv_Mat_get_Step cv_Mat_convertTo to mat.cpp
Apr 15, 2014
2f535bc
added cv_randu2,cv_goodFeaturesToTrack2,cv_create_Mat_as_vectort,cv_R…
Apr 15, 2014
83a6325
added cv_randu2,cv_goodFeaturesToTrack2,cv_create_Mat_as_vectort,cv_R…
Apr 15, 2014
cbc0503
added cv_Mat_convertTo cv_Mat_get_Step cv_Mat_convertTo to mat.cpp
Apr 15, 2014
ff170ff
added new file scalar.hpp
Apr 15, 2014
0ef6115
added cv_randu2,cv_goodFeaturesToTrack2,cv_create_Mat_as_vectort,cv_R…
Apr 15, 2014
f26d805
added cv_Mat_convertTo cv_Mat_get_Step cv_Mat_convertTo cv_delete_Mat…
Apr 16, 2014
56aa7ac
added cv_Mat_convertTo cv_Mat_get_Step cv_Mat_convertTo cv_delete_Mat…
Apr 16, 2014
dfee679
Removed unnecessary call to cabal.
Apr 16, 2014
2fa6831
Merge pull request #4 from W-Net-AI/master
Apr 16, 2014
badf14f
Added explicit getters to Rect.
Apr 21, 2014
cf31273
Added clone for easy Rect copying.
Apr 21, 2014
c3e33c9
Merge branch 'master' of github.com:arjuncomar/opencv_contrib
Apr 21, 2014
439d049
Fixed function name in rect.{cpp,hpp}
Apr 22, 2014
e0ee5e8
Added Rect to the Haskell bindings.
Apr 22, 2014
1a66df9
Added smart pointer disabling header.
Apr 24, 2014
1c2a6d6
Reverting breaking commit that introduced smartptr disabling.
Apr 29, 2014
296a340
added cv_create_CvANN_MLP_TrainParams and cv_create_CvANN_MLP_TrainPa…
May 26, 2014
0733c3e
added cv_create_CvANN_MLP_TrainParams and cv_create_CvANN_MLP_TrainPa…
May 26, 2014
45a8a13
Merge pull request #5 from W-Net-AI/master
Jun 9, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions modules/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
set(the_description "C Wrappers")

set(module_dependencies opencv_core opencv_contrib opencv_flann opencv_ml opencv_imgproc opencv_calib3d opencv_features2d opencv_video opencv_objdetect opencv_highgui opencv_photo opencv_legacy opencv_stitching opencv_superres opencv_ts opencv_nonfree)

ocv_add_module(c ${module_dependencies})

set(OPENCV_MODULE_TYPE STATIC)

set(opencv_hdrs
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/base.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/types.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/persistence.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/utility.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/mat.hpp"
"${OPENCV_MODULE_opencv_flann_LOCATION}/include/opencv2/flann/miniflann.hpp"
"${OPENCV_MODULE_opencv_imgproc_LOCATION}/include/opencv2/imgproc.hpp"
"${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/background_segm.hpp"
"${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/tracking.hpp"
"${OPENCV_MODULE_opencv_photo_LOCATION}/include/opencv2/photo.hpp"
"${OPENCV_MODULE_opencv_highgui_LOCATION}/include/opencv2/highgui.hpp"
"${OPENCV_MODULE_opencv_ml_LOCATION}/include/opencv2/ml.hpp"
"${OPENCV_MODULE_opencv_features2d_LOCATION}/include/opencv2/features2d.hpp"
"${OPENCV_MODULE_opencv_calib3d_LOCATION}/include/opencv2/calib3d.hpp"
"${OPENCV_MODULE_opencv_objdetect_LOCATION}/include/opencv2/objdetect.hpp"
"${OPENCV_MODULE_opencv_contrib_LOCATION}/include/opencv2/contrib.hpp"
"${OPENCV_MODULE_opencv_stitching_LOCATION}/include/opencv2/stitching.hpp"
"${OPENCV_MODULE_opencv_superres_LOCATION}/include/opencv2/superres.hpp"
"${OPENCV_MODULE_opencv_ts_LOCATION}/include/opencv2/ts.hpp"
"${OPENCV_MODULE_opencv_bioinspired_LOCATION}/include/opencv2/bioinspired.hpp"
)

set(opencv_hdr_dirs
"${OPENCV_MODULE_opencv_core_LOCATION}/include/"
"${OPENCV_MODULE_opencv_flann_LOCATION}/include/"
"${OPENCV_MODULE_opencv_imgproc_LOCATION}/include/"
"${OPENCV_MODULE_opencv_video_LOCATION}/include/"
"${OPENCV_MODULE_opencv_photo_LOCATION}/include/"
"${OPENCV_MODULE_opencv_highgui_LOCATION}/include/"
"${OPENCV_MODULE_opencv_ml_LOCATION}/include/"
"${OPENCV_MODULE_opencv_features2d_LOCATION}/include/"
"${OPENCV_MODULE_opencv_calib3d_LOCATION}/include/"
"${OPENCV_MODULE_opencv_objdetect_LOCATION}/include/"
"${OPENCV_MODULE_opencv_contrib_LOCATION}/include/"
"${OPENCV_MODULE_opencv_bioinspired_LOCATION}/include/"
"${OPENCV_MODULE_opencv_stitching_LOCATION}/include/"
"${OPENCV_MODULE_opencv_superres_LOCATION}/include/"
"${OPENCV_MODULE_opencv_ts_LOCATION}/include/"
"${OPENCV_MODULE_opencv_bioinspired_LOCATION}/include/"
"${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/"
)


if(HAVE_opencv_nonfree)
list(APPEND opencv_hdrs "${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/opencv2/nonfree/features2d.hpp"
"${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/opencv2/nonfree.hpp"
)
endif()

set(c_wrapper_header
"${CMAKE_CURRENT_BINARY_DIR}/include/opencv2/c/opencv_generated.hpp"
)

set(c_wrapper_source
"${CMAKE_CURRENT_BINARY_DIR}/src/opencv_generated.cpp"
)

file(GLOB headers "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h" "include/opencv2/*.h")

file(GLOB_RECURSE sources "src/*.cpp")

ocv_set_module_sources(HEADERS ${headers} ${c_wrapper_header} SOURCES ${sources} ${c_wrapper_source})

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/opencv2/c/)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include/opencv2/c/ )
add_custom_command(
OUTPUT ${c_wrapper_source} ${c_wrapper_header}
COMMAND ${CMAKE_COMMAND} -E copy ${OPENCV_MODULE_opencv_python_LOCATION}/src2/hdr_parser.py ${CMAKE_CURRENT_BINARY_DIR}/src/
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/src/genc.py" "${CMAKE_CURRENT_BINARY_DIR}/src/"
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/src/genc.py" ${CMAKE_CURRENT_BINARY_DIR} ${opencv_hdrs}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/opencv_generated.hpp ${CMAKE_CURRENT_BINARY_DIR}/include/opencv2/c/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/opencv_generated.cpp ${CMAKE_CURRENT_BINARY_DIR}/src
COMMAND ${CMAKE_COMMAND} -E copy ${c_wrapper_header} ${CMAKE_BINARY_DIR}/include/opencv2/c/
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/opencv_generated.hpp ${CMAKE_CURRENT_BINARY_DIR}/opencv_generated.cpp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/genc.py
DEPENDS ${OPENCV_MODULE_opencv_python_LOCATION}/src2/hdr_parser.py
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/opencv2/opencv.h
DEPENDS ${headers}
DEPENDS ${opencv_hdrs}
)

ocv_module_include_directories("${CMAKE_CURRENT_BINARY_DIR}/include"
"${CMAKE_SOURCE_DIR}/include"
${opencv_hdr_dirs})
ocv_create_module()
target_link_libraries(${the_module} ${module_dependencies})

add_library("${the_module}Dyn" SHARED ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES} "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp")
set_target_properties("${the_module}Dyn" PROPERTIES OUTPUT_NAME ${the_module})
add_dependencies(${the_module} ${the_module}Dyn)

if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_module} PROPERTIES FOLDER "bindings")
endif()

install(FILES ${c_wrapper_header} DESTINATION include/opencv2/c/)
install(FILES ${headers} DESTINATION include/opencv2/c/)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/opencv2/opencv.h DESTINATION include/opencv2/)
install(TARGETS ${the_module}Dyn LIBRARY DESTINATION lib)
25 changes: 25 additions & 0 deletions modules/c/include/opencv2/c/disablesmartptr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* =====================================================================================
*
* Filename: smartptr.hpp
*
* Description: Header to disable smart pointers. This enables use of the C++ api from C
* while leaving memory management up to the caller. This is good for
* binding to other languages, but will cause problems if you expect
* smart pointers to work as normal.
*
* Version: 1.0
* Created: 04/24/2014 05:31:41 PM
* Revision: none
* Compiler: g++
*
* Author: Arjun Comar
* Organization:
*
* =====================================================================================
*/

#include <opencv2/opencv.hpp>

using namespace cv;

34 changes: 34 additions & 0 deletions modules/c/include/opencv2/c/excluded_functions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* =====================================================================================
*
* Filename: excluded_functions.hpp
*
* Description: Functions that the generator outputs incorrectly, either by them entirely
* or by outputting them with incorrectly specified types.
*
* Version: 1.0
* Created: 04/13/2014 12:00:46 AM
* Revision: none
* Compiler: g++
*
* Author: Arjun Comar
*
* =====================================================================================
*/

#include <opencv2/c/opencv_generated.hpp>

extern "C" {
CvANN_MLP_TrainParams* cv_create_CvANN_MLP_TrainParams();
CvANN_MLP_TrainParams* cv_create_CvANN_MLP_TrainParams4(TermCriteria* term_crit, int train_method, double param1, double param2);
void cv_randu2(Mat* dst, Scalar* low, Scalar* high);
void cv_goodFeaturesToTrack2(Mat* image, vector_Point2f* corners, int maxCorners, double qualityLevel, double minDistance, Mat* mask, int blockSize, bool useHarrisDetector, double k);
Mat* cv_create_Mat_as_vectort(vector_Point2f* vec, bool copyData);
Size* cv_RotatedRect_size(RotatedRect* self);
Point* cv_RotatedRect_center(RotatedRect* self);
RotatedRect* cv_create_RotatedRect(Point* center, Size* size, float angle);
void cv_inRangeS(Mat* src, Scalar* lowerb, Scalar* upperb, Mat* dst);
int cv_createTrackbar(String* trackbarname, String* winname, int* value, int count, TrackbarCallback onChange, void* userdata);
void cv_setMouseCallback(String* winname, MouseCallback onMouse, void* userdata);
}

77 changes: 77 additions & 0 deletions modules/c/include/opencv2/c/mat.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* =====================================================================================
*
* Filename: mat.hpp
*
* Description: Wrappers for the OpenCV Matrix class
*
* Version: 1.0
* Created: 09/24/13 20:01:07
* Revision: none
* Compiler: g++
*
* Author: Arjun Comar
*
* =====================================================================================
*/

#include <opencv2/c/opencv_generated.hpp>

extern "C" {
Mat* cv_create_Mat();
Mat* cv_create_Mat_typed(int rows, int cols, int type);
Mat* cv_create_Mat_with_data(int rows, int cols, int type, void* data);
Mat* cv_create_Mat_with_value(int rows, int cols, int type, Scalar* s);
Mat* cv_Mat_assign(Mat* self, Mat* m);
Mat* cv_Mat_assignVal(Mat* self, Scalar* s);
Mat* cv_Mat_getRow(Mat* self, int y);
Mat* cv_Mat_getCol(Mat* self, int x);
Mat* cv_Mat_getRowRange(Mat* self, int startrow, int endrow);
Mat* cv_Mat_getColRange(Mat* self, int startrow, int endrow);
Mat* cv_Mat_diag(Mat* self);
Mat* cv_Mat_diag_d(Mat* self, int d);
Mat* cv_create_diagMat(Mat* d);
Mat* cv_Mat_clone(Mat* self);
void cv_Mat_copyTo(Mat* self, Mat* m);
void cv_Mat_copyTo_masked(Mat* self, Mat* m, Mat* mask);
void cv_Mat_assignTo(Mat* self, Mat* m);
void cv_Mat_assignTo_t(Mat*self, Mat* m, int t);
void cv_Mat_convertTo(Mat* self,Mat* m, int rtype, double alpha, double beta);
Mat* cv_Mat_setTo(Mat*self, Scalar* value);
Mat* cv_Mat_setTo_masked(Mat* self, Scalar* value, Mat* mask);
Mat* cv_Mat_reshape(Mat* self, int cn);
Mat* cv_Mat_reshape_rows(Mat* self, int cn, int rows);
size_t cv_Mat_elemSize(Mat* self);
size_t cv_Mat_elemSize1(Mat* self);
int cv_Mat_type(Mat* self);
int cv_Mat_depth(Mat* self);
size_t cv_Mat_total(Mat* self);
bool cv_Mat_isContinuous(Mat* self);
int cv_Mat_channels(Mat* self);
int cv_Mat_rows(Mat* self);
int cv_Mat_cols(Mat* self);
int cv_Mat_empty(Mat* self);
Size* cv_Mat_size(Mat* self);
size_t cv_Mat_get_Step(Mat* self);
size_t cv_Mat_step1(Mat* self);
uchar* cv_Mat_ptr(Mat* self);
uchar* cv_Mat_ptr_index(Mat* self, int i);
Mat* cv_create_identity(int rows, int cols, int type);
Mat* cv_create_ones(int rows, int cols, int type);
Mat* cv_create_zeros(int rows, int cols, int type);
MatExpr* cv_Mat_transpose_mat(Mat* self);
MatExpr* cv_Mat_inv_mat(Mat* self, int method);
MatExpr* cv_Mat_add(Mat* m1, Mat* m2);
MatExpr* cv_Mat_mult(Mat* m1, Mat* m2);
Mat* force(MatExpr* expr);
MatExpr* promote(Mat* m);
MatExpr* cv_Mat_scale(MatExpr* m, double alpha);
double cv_Mat_dot(Mat* self, Mat* m);
Mat* cv_Mat_cross(Mat* self, Mat* m);
void cv_Mat_locateROI(Mat* self, Size* s, Point* p);
Mat* cv_Mat_adjustROI(Mat* self, int dtop, int dbottom, int dleft, int dright);
void cv_delete_Mat(Mat* self);
void cv_destruct_Mat(Mat* self);
void cv_delete_MatExpr(MatExpr* self);
void cv_destruct_MatExpr(MatExpr* self);
}
37 changes: 37 additions & 0 deletions modules/c/include/opencv2/c/point.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* =====================================================================================
*
* Filename: point.hpp
*
* Description: Wrapper header for the OpenCV Point class(es)
*
* Version: 1.0
* Created: 10/02/2013 11:54:37 AM
* Revision: none
* Compiler: g++
*
* Author: Arjun Comar
*
* =====================================================================================
*/

#include <opencv2/c/opencv_generated.hpp>

#define ADD_POINT_FUNC_HEADERS(t, tn) \
Point2##t * cv_create_Point2##t ( tn x, tn y); \
Point3##t * cv_create_Point3##t ( tn x, tn y, tn z); \
tn cv_Point2##t##_getX( Point2##t * self); \
tn cv_Point2##t##_getY( Point2##t * self); \
tn cv_Point3##t##_getX( Point3##t * self); \
tn cv_Point3##t##_getY( Point3##t * self); \
tn cv_Point3##t##_getZ( Point3##t * self); \
tn cv_Point2##t##_dot( Point2##t * self, Point2##t * other); \
tn cv_Point3##t##_dot( Point3##t * self, Point3##t * other); \
Point3##t * cv_Point3##t##_cross(Point3##t * self, Point3##t * other);

extern "C" {
ADD_POINT_FUNC_HEADERS(i, int);
ADD_POINT_FUNC_HEADERS(f, float);
ADD_POINT_FUNC_HEADERS(d, double);
}

19 changes: 19 additions & 0 deletions modules/c/include/opencv2/c/rect.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef __CV_C_RECT_HPP__
#define __CV_C_RECT_HPP__
#include <opencv2/c/opencv_generated.hpp>

extern "C" {
Rect* cv_create_Rect();
Rect* cv_create_Rect4(int x, int y, int width, int height);
Rect* cv_Rect_assignTo(Rect* self, Rect* r);
Rect* cv_Rect_clone(Rect* self);
Point* cv_Rect_tl(Rect* self);
Point* cv_Rect_br(Rect* self);
int cv_Rect_getX(Rect* self);
int cv_Rect_getY(Rect* self);
int cv_Rect_getWidth(Rect* self);
int cv_Rect_getHeight(Rect* self);
Size* cv_Rect_size(Rect* self);
int cv_Rect_contains(Rect* self, Point* pt);
}
#endif
23 changes: 23 additions & 0 deletions modules/c/include/opencv2/c/scalar.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* =====================================================================================
*
* Filename: scalar.hpp
*
* Description: Wrappers for the OpenCV Matrix class
*
* Version: 1.0
* Created: 03/17/14 18:85:00
* Revision: none
* Compiler: g++
*
* Author: Arjun Comar
*
* =====================================================================================
*/

#include <opencv2/c/opencv_generated.hpp>

extern "C" {
Scalar* cv_create_Scalar(double val0, double val1, double val2, double val3);
Scalar* cv_create_scalarAll(double val0123);
}
16 changes: 16 additions & 0 deletions modules/c/include/opencv2/c/size.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef __CV_C_SIZE_HPP__
#define __CV_C_SIZE_HPP__
#include <opencv2/c/opencv_generated.hpp>

extern "C" {
Size2f* cv_create_Size2f(float width, float height);
Size* cv_create_Size();
Size* cv_create_Size2(double width, double height);
Size* cv_Size_assignTo(Size* self, Size* other);
Size* cv_Size_fromPoint(Point* p);
double cv_Size_area(Size* self);
double cv_Size_width(Size* self);
double cv_Size_height(Size* self);
}
#endif

8 changes: 8 additions & 0 deletions modules/c/include/opencv2/opencv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __OPENCV_C_H
#define __OPENCV_C_H
#include <opencv2/c/opencv_generated.hpp>
#include <opencv2/c/mat.hpp>
#include <opencv2/c/point.hpp>
#include <opencv2/c/rect.hpp>
#include <opencv2/c/size.hpp>
#endif //__OPENCV_C_H
Loading