diff --git a/ext/opencv/mat.cpp b/ext/opencv/mat.cpp index 4920a2a..40d6f82 100644 --- a/ext/opencv/mat.cpp +++ b/ext/opencv/mat.cpp @@ -278,9 +278,9 @@ namespace rubyopencv { * Saves an image to a specified file. * The image format is chosen based on the filename extension. * - * @overload save(filename, params = []) + * @overload save(filename, params = nil) * @param filename [String] Name of the file - * @return [Boolean] + * @return [Boolean] Result * @opencv_func cv::imwrite */ VALUE rb_save(int argc, VALUE* argv, VALUE self) { @@ -317,6 +317,15 @@ namespace rubyopencv { return array; } + /* + * Encodes an image into a memory buffer. + * + * @overload imencode(ext, params = nil) + * @param ext [String] File extension that defines the output format. + * @param params [Array] Format-specific parameters. + * @return [Array] Encoded result + * @opencv_func cv::imwrite + */ VALUE rb_imencode(int argc, VALUE* argv, VALUE self) { VALUE ext, params; rb_scan_args(argc, argv, "11", &ext, ¶ms); @@ -577,6 +586,14 @@ namespace rubyopencv { return self; } + /* + * Computes the per-element sum of two arrays or an array and a scalar. + * + * @overload +(value) + * @param value [Mat, Scalar] Array or scalar to add + * @return [Mat] Result array + * @opencv_func cv::Mat::operator+ + */ VALUE rb_add(VALUE self, VALUE other) { cv::Mat* selfptr = obj2mat(self); cv::Mat* retptr = empty_mat(); @@ -605,6 +622,14 @@ namespace rubyopencv { return mat2obj(retptr, CLASS_OF(self)); } + /* + * Computes the per-element difference of two arrays or an array and a scalar. + * + * @overload -(value) + * @param value [Mat, Scalar] Array or scalar to subtract + * @return [Mat] Result array + * @opencv_func cv::Mat::operator- + */ VALUE rb_sub(VALUE self, VALUE other) { cv::Mat* selfptr = obj2mat(self); cv::Mat* retptr = empty_mat(); @@ -633,6 +658,14 @@ namespace rubyopencv { return mat2obj(retptr, CLASS_OF(self)); } + /* + * Computes the per-element product of two arrays or an array and a scalar. + * + * @overload -(value) + * @param value [Mat, Scalar] Array or scalar to multiply + * @return [Mat] Result array + * @opencv_func cv::Mat::operator* + */ VALUE rb_mul(VALUE self, VALUE other) { cv::Mat* selfptr = obj2mat(self); cv::Mat* retptr = empty_mat(); @@ -657,6 +690,14 @@ namespace rubyopencv { return mat2obj(retptr, CLASS_OF(self)); } + /* + * Computes the per-element division of two arrays or an array and a scalar. + * + * @overload /(value) + * @param value [Mat, Scalar] Array or scalar to divide + * @return [Mat] Result array + * @opencv_func cv::Mat::operator/ + */ VALUE rb_div(VALUE self, VALUE other) { cv::Mat* selfptr = obj2mat(self); cv::Mat* retptr = empty_mat(); diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index 6486ecb..fd70b0c 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -30,17 +30,47 @@ namespace rubyopencv { return 0; } + /* + * Returns full configuration time cmake output. + * Returned value is raw cmake output including version control system revision, + * compiler version, compiler flags, enabled modules and third party libraries, etc. + * Output format depends on target architecture. + * + * @overload rb_build_information() + * @return [String] Full configuration time cmake output. + * @opencv_func cv::getBuildInformation + */ VALUE rb_build_information(VALUE klass) { const char* ptr = cv::getBuildInformation().c_str(); return rb_str_new(ptr, strlen(ptr)); } + /* + * Saves an image to a specified file. + * + * @overload imwrite(filename, img, params = nil) + * @param filename [String] Name of the file. + * @param img [Mat] Image to be saved. + * @param params [Array] + * Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...) + * @return [Bool] Result + * @opencv_func cv::imwrite + */ VALUE rb_imwrite(int argc, VALUE* argv, VALUE self) { VALUE filename, img, params; rb_scan_args(argc, argv, "21", &filename, &img, ¶ms); return Mat::rb_imwrite_internal(filename, img, params); } + /* + * Makes a type from depth and channels + * + * @overload CV_MAKETYPE(depth, cn) + * @param depth [String] Depth + * @param cn [Mat] Number of channels + * @return [Integer] Type + * @opencv_func CV_MAKETYPE + */ VALUE rb_maketype(VALUE self, VALUE depth, VALUE channels) { int type = CV_MAKETYPE(NUM2INT(depth), NUM2INT(channels)); return INT2NUM(type); diff --git a/ext/opencv/rect.cpp b/ext/opencv/rect.cpp index 5f044a9..9cc1686 100644 --- a/ext/opencv/rect.cpp +++ b/ext/opencv/rect.cpp @@ -44,6 +44,16 @@ namespace rubyopencv { return TypedData_Wrap_Struct(klass, &opencv_rect_type, ptr); } + /* + * Create a rectangle + * + * @overload new(x = 0, y = 0, width = 0, height = 0) + * @param x [Integer] x coordinate + * @param y [Integer] y coordinate + * @param width [Integer] Width + * @param height [Integer] Height + * @return [Rect] new rectangle + */ VALUE rb_initialize(int argc, VALUE *argv, VALUE self) { const int SIZE = 4; VALUE values[SIZE]; @@ -100,19 +110,45 @@ namespace rubyopencv { return self; } + /* + * Return width + * + * @overload width + * @return [Integer] Width + */ VALUE rb_width(VALUE self) { return INT2NUM(obj2rect(self)->width); } + /* + * Set width + * + * @overload width=(value) + * @param value [Integer] Width + * @return [Rect] +self+ + */ VALUE rb_set_width(VALUE self, VALUE width) { obj2rect(self)->width = NUM2INT(width); return self; } + /* + * Return height + * + * @overload height + * @return [Integer] Height + */ VALUE rb_height(VALUE self) { return INT2NUM(obj2rect(self)->height); } + /* + * Set height + * + * @overload height=(value) + * @param value [Integer] Height + * @return [Rect] +self+ + */ VALUE rb_set_height(VALUE self, VALUE height) { obj2rect(self)->height = NUM2INT(height); return self; diff --git a/ext/opencv/size.cpp b/ext/opencv/size.cpp index 422cf2f..9fb834e 100644 --- a/ext/opencv/size.cpp +++ b/ext/opencv/size.cpp @@ -41,19 +41,45 @@ namespace rubyopencv { return TypedData_Wrap_Struct(klass, &opencv_size_type, ptr); } + /* + * Return width + * + * @overload width + * @return [Integer] Width + */ VALUE rb_width(VALUE self) { return INT2NUM(obj2size(self)->width); } + /* + * Set width + * + * @overload width=(value) + * @param value [Integer] Width + * @return [Mat] +self+ + */ VALUE rb_set_width(VALUE self, VALUE width) { obj2size(self)->width = NUM2INT(width); return self; } + /* + * Return height + * + * @overload height + * @return [Integer] Height + */ VALUE rb_height(VALUE self) { return INT2NUM(obj2size(self)->height); } + /* + * Set height + * + * @overload height=(value) + * @param value [Integer] Height + * @return [Mat] +self+ + */ VALUE rb_set_height(VALUE self, VALUE height) { obj2size(self)->height = NUM2INT(height); return self; diff --git a/ext/opencv/videocapture.cpp b/ext/opencv/videocapture.cpp index eaa6a46..b3d4712 100644 --- a/ext/opencv/videocapture.cpp +++ b/ext/opencv/videocapture.cpp @@ -45,6 +45,7 @@ namespace rubyopencv { /* * Open video file or a capturing device for video capturing + * * @scope class * @overload new(device = 0) * @param device [String, Fixnum, nil] Video capturing device @@ -96,6 +97,13 @@ namespace rubyopencv { return Mat::mat2obj(m); } + /* + * Returns true if video capturing has been initialized already. + * + * @overload opened? + * @return [Boolean] The video capturing has been initialized already or not. + * @opencv_func cv::VideoCapture::isOpened + */ VALUE rb_is_opened(VALUE self) { cv::VideoCapture* selfptr = obj2videocapture(self); bool is_opened = false; @@ -111,6 +119,30 @@ namespace rubyopencv { /* * Returns the specified VideoCapture property. + * + * @overload get(prop_id) + * @param prop_id [Integer] Property identifier. It can be one of the following: + * - CAP_PROP_POS_MSEC - Current position of the video file in milliseconds. + * - CAP_PROP_POS_FRAMES - 0-based index of the frame to be decoded/captured next. + * - CAP_PROP_POS_AVI_RATIO - Relative position of the video file: 0 - start of the film, 1 - end of the film. + * - CAP_PROP_FRAME_WIDTH - Width of the frames in the video stream. + * - CAP_PROP_FRAME_HEIGHT - Height of the frames in the video stream. + * - CAP_PROP_FPS - Frame rate. + * - CAP_PROP_FOURCC - 4-character code of codec. + * - CAP_PROP_FRAME_COUNT - Number of frames in the video file. + * - CAP_PROP_FORMAT - Format of the Mat objects returned by retrieve() . + * - CAP_PROP_MODE - Backend-specific value indicating the current capture mode. + * - CAP_PROP_BRIGHTNESS - Brightness of the image (only for cameras). + * - CAP_PROP_CONTRAST - Contrast of the image (only for cameras). + * - CAP_PROP_SATURATION - Saturation of the image (only for cameras). + * - CAP_PROP_HUE - Hue of the image (only for cameras). + * - CAP_PROP_GAIN - Gain of the image (only for cameras). + * - CAP_PROP_EXPOSURE - Exposure (only for cameras). + * - CAP_PROP_CONVERT_RGB - Boolean flags indicating whether images should be converted to RGB. + * - CAP_PROP_WHITE_BALANCE - Currently unsupported + * - CAP_PROP_RECTIFICATION - Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently) + * @return [Number] VideoCapture property + * @opencv_func cv::VideoCapture::get */ VALUE rb_get(VALUE self, VALUE prop_id) { cv::VideoCapture* selfptr = obj2videocapture(self); @@ -127,6 +159,31 @@ namespace rubyopencv { /* * Sets a property in the VideoCapture. + * + * @overload set(prop_id, value) + * @param prop_id [Integer] Property identifier. It can be one of the following: + * - CAP_PROP_POS_MSEC - Current position of the video file in milliseconds. + * - CAP_PROP_POS_FRAMES - 0-based index of the frame to be decoded/captured next. + * - CAP_PROP_POS_AVI_RATIO - Relative position of the video file: 0 - start of the film, 1 - end of the film. + * - CAP_PROP_FRAME_WIDTH - Width of the frames in the video stream. + * - CAP_PROP_FRAME_HEIGHT - Height of the frames in the video stream. + * - CAP_PROP_FPS - Frame rate. + * - CAP_PROP_FOURCC - 4-character code of codec. + * - CAP_PROP_FRAME_COUNT - Number of frames in the video file. + * - CAP_PROP_FORMAT - Format of the Mat objects returned by retrieve() . + * - CAP_PROP_MODE - Backend-specific value indicating the current capture mode. + * - CAP_PROP_BRIGHTNESS - Brightness of the image (only for cameras). + * - CAP_PROP_CONTRAST - Contrast of the image (only for cameras). + * - CAP_PROP_SATURATION - Saturation of the image (only for cameras). + * - CAP_PROP_HUE - Hue of the image (only for cameras). + * - CAP_PROP_GAIN - Gain of the image (only for cameras). + * - CAP_PROP_EXPOSURE - Exposure (only for cameras). + * - CAP_PROP_CONVERT_RGB - Boolean flags indicating whether images should be converted to RGB. + * - CAP_PROP_WHITE_BALANCE - Currently unsupported + * - CAP_PROP_RECTIFICATION - Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently) + * @param value [Number] Value of the property + * @return [Boolean] Result + * @opencv_func cv::VideoCapture::set */ VALUE rb_set(VALUE self, VALUE prop_id, VALUE value) { cv::VideoCapture* selfptr = obj2videocapture(self); @@ -143,6 +200,7 @@ namespace rubyopencv { /* * Grabs the next frame from video file or capturing device. + * * @overload grab * @return [Boolean] If grabbing a frame successed, returns true, otherwise returns false. * @opencv_func cv::VideCapture.grab @@ -162,6 +220,7 @@ namespace rubyopencv { /* * Decodes and returns the grabbed video frame. + * * @overload retrieve * @return [Mat] Grabbed video frame * @return [nil] Failed to grabbing a frame