Add calib3d to julia bindings

pull/2664/head
Archit Rungta 5 years ago
parent e320d6aad0
commit df3d848a35
  1. 1
      modules/julia/CMakeLists.txt
  2. 2
      modules/julia/README.md
  3. 25
      modules/julia/gen/binding_templates_cpp/cv_core.cpp
  4. 5
      modules/julia/gen/cpp_files/jlcv.hpp
  5. 36
      modules/julia/gen/defval.txt
  6. 118
      modules/julia/gen/funclist.csv
  7. 15
      modules/julia/gen/gen3_julia_cxx.py
  8. 2
      modules/julia/gen/gen_all.py
  9. 5
      modules/julia/gen/typemap.txt
  10. 19
      modules/julia/samples/chessboard_corners.jl
  11. 2
      modules/julia/tutorials/julia.markdown

@ -68,6 +68,7 @@ ocv_add_module(
opencv_dnn
opencv_features2d
opencv_objdetect
opencv_calib3d
)
set(HDR_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/python/src2/hdr_parser.py)

@ -88,4 +88,4 @@ All other types map directly to the corresponding types on C++. Unlike Python, `
Current Functionality
---
The bindings implement most of the functionality present in the core,imgproc,highgui,videoio,dnn and imgcodecs. The samples also implement some additional manually wrapped functionality. The complete list of automatically wrapped functionality is [here](gen/funclist.csv).
The bindings implement most of the functionality present in the core,imgproc,highgui,videoio,dnn,calib3d and imgcodecs. The samples also implement some additional manually wrapped functionality. The complete list of automatically wrapped functionality is [here](gen/funclist.csv).

@ -41,11 +41,12 @@ ${include_code}
//
#ifdef HAVE_OPENCV_FEATURES2D
template <>
struct SuperType<cv::Feature2D>
{
typedef cv::Algorithm type;
};
// template <>
// struct SuperType<cv::Feature2D>
// {
// typedef cv::Algorithm type;
// };
// TODO: Needs to be fixed but doesn't matter for now
template <>
struct SuperType<cv::SimpleBlobDetector>
{
@ -88,7 +89,6 @@ JLCXX_MODULE cv_wrap(jlcxx::Module &mod)
${cpp_code}
//
// Manual Wrapping BEGIN
@ -128,16 +128,21 @@ JLCXX_MODULE cv_wrap(jlcxx::Module &mod)
#endif
#ifdef HAVE_OPENCV_FEATURES2D
mod.add_type<cv::Feature2D>("Feature2D", jlcxx::julia_base_type<cv::Algorithm>());
mod.add_type<cv::Feature2D>("Feature2D");
mod.add_type<cv::SimpleBlobDetector>("SimpleBlobDetector", jlcxx::julia_base_type<cv::Feature2D>());
mod.add_type<cv::SimpleBlobDetector::Params>("SimpleBlobDetector_Params");
mod.method("jlopencv_cv_cv_Feature2D_cv_Feature2D_detect", [](cv::Ptr<cv::Feature2D> &cobj, Mat &image, Mat &mask) {vector<KeyPoint> keypoints; cobj->detect(image, keypoints, mask); return keypoints; });
mod.method("jlopencv_cv_cv_SimpleBlobDetector_create", [](SimpleBlobDetector_Params &parameters) { auto retval = cv::SimpleBlobDetector::create(parameters); return retval; });
#endif
//
// Manual Wrapping END
//
${cpp_code}
#ifdef HAVE_OPENCV_FEATURES2D
mod.method("jlopencv_cv_cv_Feature2D_cv_Feature2D_detect", [](cv::Ptr<cv::Feature2D> &cobj, Mat &image, Mat &mask) {vector<KeyPoint> keypoints; cobj->detect(image, keypoints, mask); return keypoints; });
mod.method("jlopencv_cv_cv_SimpleBlobDetector_create", [](SimpleBlobDetector_Params &parameters) { auto retval = cv::SimpleBlobDetector::create(parameters); return retval; });
#endif
}

@ -75,6 +75,11 @@ typedef cv::dnn::DictValue LayerId;
typedef cv::dnn::Backend dnn_Backend;
#endif
#ifdef HAVE_OPENCV_CALIB3D
#include <opencv2/calib3d.hpp>
#endif
template <typename C>
struct get_template_type;
template <typename C>

@ -65,4 +65,38 @@ Int32|0|0
Float64|255.|255
Scalar|Scalar(1)|cpp_to_julia(ScalarOXP())
Int32|1|1
Size{Int32}|Size()|cpp_to_julia(SizeOP())
Size{Int32}|Size()|cpp_to_julia(SizeOP())
TermCriteria|TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON)|cpp_to_julia(TermCriteriaOTermCriteriaggEPSGRGTermCriteriaggCOUNTSGYWSGFLTREPSILONP())
Int32|RANSAC|cv_RANSAC
Float32|8.0|8.0
Float64|-1|-1
Int32|21|21
TermCriteria|TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON)|TermCriteriaOGTermCriteriaggCOUNTGRGTermCriteriaggEPSSGZWSGDBLREPSILONP
TermCriteria|TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6)|TermCriteriaOTermCriteriaggCOUNTRTermCriteriaggEPSSGZWSGXeTcP
Int32|CALIB_CB_SYMMETRIC_GRID|cv_CALIB_CB_SYMMETRIC_GRID
InputArray|cv::Mat()|CxxMat()
Int32|SOLVEPNP_ITERATIVE|cv_SOLVEPNP_ITERATIVE
Float64|3|3
Int32|CALIB_FIX_INTRINSIC|cv_CALIB_FIX_INTRINSIC
Float64|5|5
Float64|0.99|0.99
Int32|CALIB_ZERO_DISPARITY|cv_CALIB_ZERO_DISPARITY
size_t|2000|2000
SolvePnPMethod|SOLVEPNP_ITERATIVE|cv_SOLVEPNP_ITERATIVE
Float64|0.0|0.0
Ptr{Feature2D}|SimpleBlobDetector::create()|SimpleBlobDetectorggcreateOP
Int32|StereoSGBM::MODE_SGBM|StereoSGBMggMODERSGBM
Int32|CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE|cv_CALIB_CB_ADAPTIVE_THRESH + cv_CALIB_CB_NORMALIZE_IMAGE
Float64|3.|3
size_t|10|10
Int32|16|16
Point{Float64}|Point2d(0, 0)|PointYdOWSGWP
Int32|2000|2000
Int32|FM_RANSAC|cv_FM_RANSAC
Int32|100|100
TermCriteria|TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)|TermCriteriaOTermCriteriaggCOUNTGRGTermCriteriaggEPSSGXWWSGDBLREPSILONP
HandEyeCalibrationMethod|CALIB_HAND_EYE_TSAI|cv_CALIB_HAND_EYE_TSAI
Float32|0.8F|0.8
Int32|fisheye::CALIB_FIX_INTRINSIC|cv_fisheye_CALIB_FIX_INTRINSIC
Float64|0.999|0.999
Float64|0.995|0.995

@ -373,4 +373,120 @@ cv.setTrackbarMax
cv.setTrackbarMin
cv.addText
cv.displayOverlay
cv.displayStatusBar
cv.displayStatusBar
cv.Rodrigues
cv.findHomography
cv.RQDecomp3x3
cv.decomposeProjectionMatrix
cv.matMulDeriv
cv.composeRT
cv.projectPoints
cv.solvePnP
cv.solvePnPRansac
cv.solveP3P
cv.solvePnPRefineLM
cv.solvePnPRefineVVS
cv.solvePnPGeneric
cv.initCameraMatrix2D
cv.findChessboardCorners
cv.checkChessboard
cv.findChessboardCornersSB
cv.findChessboardCornersSB
cv.estimateChessboardSharpness
cv.find4QuadCornerSubpix
cv.drawChessboardCorners
cv.drawFrameAxes
cv.CirclesGridFinderParameters.CirclesGridFinderParameters
cv.findCirclesGrid
cv.findCirclesGrid
cv.calibrateCamera
cv.calibrateCamera
cv.calibrateCameraRO
cv.calibrateCameraRO
cv.calibrationMatrixValues
cv.stereoCalibrate
cv.stereoCalibrate
cv.stereoRectify
cv.stereoRectifyUncalibrated
cv.rectify3Collinear
cv.getOptimalNewCameraMatrix
cv.calibrateHandEye
cv.convertPointsToHomogeneous
cv.convertPointsFromHomogeneous
cv.findFundamentalMat
cv.findFundamentalMat
cv.findEssentialMat
cv.findEssentialMat
cv.decomposeEssentialMat
cv.recoverPose
cv.recoverPose
cv.recoverPose
cv.computeCorrespondEpilines
cv.triangulatePoints
cv.correctMatches
cv.filterSpeckles
cv.getValidDisparityROI
cv.validateDisparity
cv.reprojectImageTo3D
cv.sampsonDistance
cv.estimateAffine3D
cv.estimateTranslation3D
cv.estimateAffine2D
cv.estimateAffinePartial2D
cv.decomposeHomographyMat
cv.filterHomographyDecompByVisibleRefpoints
cv.StereoMatcher.compute
cv.StereoMatcher.getMinDisparity
cv.StereoMatcher.setMinDisparity
cv.StereoMatcher.getNumDisparities
cv.StereoMatcher.setNumDisparities
cv.StereoMatcher.getBlockSize
cv.StereoMatcher.setBlockSize
cv.StereoMatcher.getSpeckleWindowSize
cv.StereoMatcher.setSpeckleWindowSize
cv.StereoMatcher.getSpeckleRange
cv.StereoMatcher.setSpeckleRange
cv.StereoMatcher.getDisp12MaxDiff
cv.StereoMatcher.setDisp12MaxDiff
cv.StereoBM.getPreFilterType
cv.StereoBM.setPreFilterType
cv.StereoBM.getPreFilterSize
cv.StereoBM.setPreFilterSize
cv.StereoBM.getPreFilterCap
cv.StereoBM.setPreFilterCap
cv.StereoBM.getTextureThreshold
cv.StereoBM.setTextureThreshold
cv.StereoBM.getUniquenessRatio
cv.StereoBM.setUniquenessRatio
cv.StereoBM.getSmallerBlockSize
cv.StereoBM.setSmallerBlockSize
cv.StereoBM.getROI1
cv.StereoBM.setROI1
cv.StereoBM.getROI2
cv.StereoBM.setROI2
cv.StereoBM.create
cv.StereoSGBM.getPreFilterCap
cv.StereoSGBM.setPreFilterCap
cv.StereoSGBM.getUniquenessRatio
cv.StereoSGBM.setUniquenessRatio
cv.StereoSGBM.getP1
cv.StereoSGBM.setP1
cv.StereoSGBM.getP2
cv.StereoSGBM.setP2
cv.StereoSGBM.getMode
cv.StereoSGBM.setMode
cv.StereoSGBM.create
cv.undistort
cv.initUndistortRectifyMap
cv.getDefaultNewCameraMatrix
cv.undistortPoints
cv.undistortPoints
cv.fisheye.projectPoints
cv.fisheye.distortPoints
cv.fisheye.undistortPoints
cv.fisheye.initUndistortRectifyMap
cv.fisheye.undistortImage
cv.fisheye.estimateNewCameraMatrixForUndistortRectify
cv.fisheye.calibrate
cv.fisheye.stereoRectify
cv.fisheye.stereoCalibrate

1 cv.borderInterpolate
373 cv.setTrackbarMin
374 cv.addText
375 cv.displayOverlay
376 cv.displayStatusBar
377 cv.Rodrigues
378 cv.findHomography
379 cv.RQDecomp3x3
380 cv.decomposeProjectionMatrix
381 cv.matMulDeriv
382 cv.composeRT
383 cv.projectPoints
384 cv.solvePnP
385 cv.solvePnPRansac
386 cv.solveP3P
387 cv.solvePnPRefineLM
388 cv.solvePnPRefineVVS
389 cv.solvePnPGeneric
390 cv.initCameraMatrix2D
391 cv.findChessboardCorners
392 cv.checkChessboard
393 cv.findChessboardCornersSB
394 cv.findChessboardCornersSB
395 cv.estimateChessboardSharpness
396 cv.find4QuadCornerSubpix
397 cv.drawChessboardCorners
398 cv.drawFrameAxes
399 cv.CirclesGridFinderParameters.CirclesGridFinderParameters
400 cv.findCirclesGrid
401 cv.findCirclesGrid
402 cv.calibrateCamera
403 cv.calibrateCamera
404 cv.calibrateCameraRO
405 cv.calibrateCameraRO
406 cv.calibrationMatrixValues
407 cv.stereoCalibrate
408 cv.stereoCalibrate
409 cv.stereoRectify
410 cv.stereoRectifyUncalibrated
411 cv.rectify3Collinear
412 cv.getOptimalNewCameraMatrix
413 cv.calibrateHandEye
414 cv.convertPointsToHomogeneous
415 cv.convertPointsFromHomogeneous
416 cv.findFundamentalMat
417 cv.findFundamentalMat
418 cv.findEssentialMat
419 cv.findEssentialMat
420 cv.decomposeEssentialMat
421 cv.recoverPose
422 cv.recoverPose
423 cv.recoverPose
424 cv.computeCorrespondEpilines
425 cv.triangulatePoints
426 cv.correctMatches
427 cv.filterSpeckles
428 cv.getValidDisparityROI
429 cv.validateDisparity
430 cv.reprojectImageTo3D
431 cv.sampsonDistance
432 cv.estimateAffine3D
433 cv.estimateTranslation3D
434 cv.estimateAffine2D
435 cv.estimateAffinePartial2D
436 cv.decomposeHomographyMat
437 cv.filterHomographyDecompByVisibleRefpoints
438 cv.StereoMatcher.compute
439 cv.StereoMatcher.getMinDisparity
440 cv.StereoMatcher.setMinDisparity
441 cv.StereoMatcher.getNumDisparities
442 cv.StereoMatcher.setNumDisparities
443 cv.StereoMatcher.getBlockSize
444 cv.StereoMatcher.setBlockSize
445 cv.StereoMatcher.getSpeckleWindowSize
446 cv.StereoMatcher.setSpeckleWindowSize
447 cv.StereoMatcher.getSpeckleRange
448 cv.StereoMatcher.setSpeckleRange
449 cv.StereoMatcher.getDisp12MaxDiff
450 cv.StereoMatcher.setDisp12MaxDiff
451 cv.StereoBM.getPreFilterType
452 cv.StereoBM.setPreFilterType
453 cv.StereoBM.getPreFilterSize
454 cv.StereoBM.setPreFilterSize
455 cv.StereoBM.getPreFilterCap
456 cv.StereoBM.setPreFilterCap
457 cv.StereoBM.getTextureThreshold
458 cv.StereoBM.setTextureThreshold
459 cv.StereoBM.getUniquenessRatio
460 cv.StereoBM.setUniquenessRatio
461 cv.StereoBM.getSmallerBlockSize
462 cv.StereoBM.setSmallerBlockSize
463 cv.StereoBM.getROI1
464 cv.StereoBM.setROI1
465 cv.StereoBM.getROI2
466 cv.StereoBM.setROI2
467 cv.StereoBM.create
468 cv.StereoSGBM.getPreFilterCap
469 cv.StereoSGBM.setPreFilterCap
470 cv.StereoSGBM.getUniquenessRatio
471 cv.StereoSGBM.setUniquenessRatio
472 cv.StereoSGBM.getP1
473 cv.StereoSGBM.setP1
474 cv.StereoSGBM.getP2
475 cv.StereoSGBM.setP2
476 cv.StereoSGBM.getMode
477 cv.StereoSGBM.setMode
478 cv.StereoSGBM.create
479 cv.undistort
480 cv.initUndistortRectifyMap
481 cv.getDefaultNewCameraMatrix
482 cv.undistortPoints
483 cv.undistortPoints
484 cv.fisheye.projectPoints
485 cv.fisheye.distortPoints
486 cv.fisheye.undistortPoints
487 cv.fisheye.initUndistortRectifyMap
488 cv.fisheye.undistortImage
489 cv.fisheye.estimateNewCameraMatrixForUndistortRectify
490 cv.fisheye.calibrate
491 cv.fisheye.stereoRectify
492 cv.fisheye.stereoCalibrate

@ -50,21 +50,6 @@ def handle_def_arg(inp, tp = '', ns=''):
inp = inp.strip()
out = ''
if tp in julia_types:
out = inp
elif not inp or inp=='Mat()':
if tp=='Mat' or tp=='InputArray':
out= 'CxxMat()'
out = tp+'()'
elif inp=="String()":
out= '""'
elif '(' in inp or ':' in inp:
out = "cpp_to_julia("+get_var(inp)+"())"
else:
print("Default not found")
if inp in jl_cpp_defmap[tp]:
out = jl_cpp_defmap[tp][inp]

@ -32,6 +32,8 @@ for module in sys.argv[2:]:
hdr_list.append(mod_path+"/videoio/include/opencv2/videoio.hpp")
elif module =='opencv_highgui':
hdr_list.append(mod_path+"/highgui/include/opencv2/highgui.hpp")
elif module =='opencv_calib3d':
hdr_list.append(mod_path+"/calib3d/include/opencv2/calib3d.hpp")
if not os.path.exists('autogen_cpp'):
os.makedirs('autogen_cpp')

@ -45,3 +45,8 @@ vector<MatShape>:Array{Array{Int32, 1}, 1}
float:Float32
Ptr<float>:Ptr{Float32}
vector<Vec6f>:Array{Vec{Float32, 6}, 1}
Ptr<FeatureDetector>:Ptr{Feature2D}
Point2d:Point{Float64}
SolvePnPMethod:SolvePnPMethod
CirclesGridFinderParameters:CirclesGridFinderParameters
HandEyeCalibrationMethod:HandEyeCalibrationMethod

@ -0,0 +1,19 @@
using OpenCV
const cv = OpenCV
# chess1.png is at https://raw.githubusercontent.com/opencv/opencv_extra/master/testdata/cv/cameracalibration/chess1.png
img = cv.imread("chess1.png",cv.IMREAD_GRAYSCALE)
# Find the chess board corners
ret, corners = cv.findChessboardCorners(img, cv.Size{Int32}(7,5))
# If found, add object points, image points (after refining them)
if ret
img = cv.drawChessboardCorners(img, cv.Size{Int32}(7,5), corners,ret)
cv.imshow("img",img)
cv.waitKey(Int32(0))
cv.destroyAllWindows()
end

@ -16,7 +16,7 @@ Inspite of all this, Julia severely lacks in a lot of traditional computer visio
The Bindings
-----------------------
The OpenCV bindings for Julia are created automatically using Python scripts at configure time and then installed with the Julia package manager on the system. These bindings cover most of the important functionality present in the core, imgproc, imgcodecs, highgui, videio, and dnn modules. These bindings depend on CxxWrap.jl and the process for usage and compilation is explained in detail below. The Bindings have been tested on Ubuntu and Mac. Windows might work but is not officially tested and supported right now.
The OpenCV bindings for Julia are created automatically using Python scripts at configure time and then installed with the Julia package manager on the system. These bindings cover most of the important functionality present in the core, imgproc, imgcodecs, highgui, videio, calib3d, and dnn modules. These bindings depend on CxxWrap.jl and the process for usage and compilation is explained in detail below. The Bindings have been tested on Ubuntu and Mac. Windows might work but is not officially tested and supported right now.
The generation process and the method by which the binding works are similar to the Python bindings. The only major difference is that CxxWrap.jl does not support optional arguments. As a consequence, it's necessary to define the optional arguments in Julia code which adds a lot of additional complexity.

Loading…
Cancel
Save