opencv 0.14.0

Rust bindings for OpenCV
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
//! # Images stitching
//! 
//! This figure illustrates the stitching module pipeline implemented in the Stitcher class. Using that
//! class it's possible to configure/remove some steps, i.e. adjust the stitching pipeline according to
//! the particular needs. All building blocks from the pipeline are available in the detail namespace,
//! one can combine and use them separately.
//! 
//! The implemented stitching pipeline is very similar to the one proposed in [BL07](https://docs.opencv.org/3.4.6/d0/de3/citelist.html#CITEREF_BL07) .
//! 
//! ![stitching pipeline](https://docs.opencv.org/3.4.6/StitchingPipeline.jpg)
//! 
//! Camera models
//! -------------
//! 
//! There are currently 2 camera models implemented in stitching pipeline.
//! 
//! - _Homography model_ expecting perspective transformations between images
//! implemented in @ref cv::detail::BestOf2NearestMatcher cv::detail::HomographyBasedEstimator
//! cv::detail::BundleAdjusterReproj cv::detail::BundleAdjusterRay
//! - _Affine model_ expecting affine transformation with 6 DOF or 4 DOF implemented in
//! @ref cv::detail::AffineBestOf2NearestMatcher cv::detail::AffineBasedEstimator
//! cv::detail::BundleAdjusterAffine cv::detail::BundleAdjusterAffinePartial cv::AffineWarper
//! 
//! Homography model is useful for creating photo panoramas captured by camera,
//! while affine-based model can be used to stitch scans and object captured by
//! specialized devices. Use @ref cv::Stitcher::create to get preconfigured pipeline for one
//! of those models.
//! 
//! 
//! Note:
//! Certain detailed settings of @ref cv::Stitcher might not make sense. Especially
//! you should not mix classes implementing affine model and classes implementing
//! Homography model, as they work with different transformations.
//! # Features Finding and Images Matching
//! # Rotation Estimation
//! # Autocalibration
//! # Images Warping
//! # Seam Estimation
//! # Exposure Compensation
//! # Image Blenders
use std::os::raw::{c_char, c_void};
use libc::size_t;
use crate::{Error, Result, core, sys, types};

pub const Stitcher_ERR_CAMERA_PARAMS_ADJUST_FAIL: i32 = 3;
pub const Stitcher_ERR_HOMOGRAPHY_EST_FAIL: i32 = 2;
pub const Stitcher_ERR_NEED_MORE_IMGS: i32 = 1;
pub const Stitcher_OK: i32 = 0;
pub const Stitcher_ORIG_RESOL: i32 = -1;
pub const Stitcher_PANORAMA: i32 = 0;
pub const Stitcher_SCANS: i32 = 1;

///
/// ## C++ default parameters
/// * try_use_gpu: false
pub fn create_stitcher_scans(try_use_gpu: bool) -> Result<types::PtrOfStitcher> {
    unsafe { sys::cv_createStitcherScans_bool(try_use_gpu) }.into_result().map(|x| types::PtrOfStitcher { ptr: x })
}

///
/// ## C++ default parameters
/// * try_use_gpu: false
pub fn create_stitcher(try_use_gpu: bool) -> Result<types::PtrOfStitcher> {
    unsafe { sys::cv_createStitcher_bool(try_use_gpu) }.into_result().map(|x| types::PtrOfStitcher { ptr: x })
}

// boxed class cv::AffineWarper
/// Affine warper factory class.
/// ## See also
/// detail::AffineWarper
#[allow(dead_code)]
pub struct AffineWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::AffineWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_AffineWarper_delete(self.ptr) };
    }
}
impl crate::stitching::AffineWarper {
    pub fn as_raw_AffineWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        AffineWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for AffineWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl AffineWarper {

}

// boxed class cv::CompressedRectilinearPortraitWarper
#[allow(dead_code)]
pub struct CompressedRectilinearPortraitWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::CompressedRectilinearPortraitWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_CompressedRectilinearPortraitWarper_delete(self.ptr) };
    }
}
impl crate::stitching::CompressedRectilinearPortraitWarper {
    pub fn as_raw_CompressedRectilinearPortraitWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        CompressedRectilinearPortraitWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for CompressedRectilinearPortraitWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl CompressedRectilinearPortraitWarper {

    ///
    /// ## C++ default parameters
    /// * a: 1
    /// * b: 1
    pub fn new(a: f32, b: f32) -> Result<crate::stitching::CompressedRectilinearPortraitWarper> {
        unsafe { sys::cv_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper_float_float(a, b) }.into_result().map(|x| crate::stitching::CompressedRectilinearPortraitWarper { ptr: x })
    }
    
}

// boxed class cv::CompressedRectilinearWarper
#[allow(dead_code)]
pub struct CompressedRectilinearWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::CompressedRectilinearWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_CompressedRectilinearWarper_delete(self.ptr) };
    }
}
impl crate::stitching::CompressedRectilinearWarper {
    pub fn as_raw_CompressedRectilinearWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        CompressedRectilinearWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for CompressedRectilinearWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl CompressedRectilinearWarper {

    ///
    /// ## C++ default parameters
    /// * a: 1
    /// * b: 1
    pub fn new(a: f32, b: f32) -> Result<crate::stitching::CompressedRectilinearWarper> {
        unsafe { sys::cv_CompressedRectilinearWarper_CompressedRectilinearWarper_float_float(a, b) }.into_result().map(|x| crate::stitching::CompressedRectilinearWarper { ptr: x })
    }
    
}

// boxed class cv::CylindricalWarper
/// Cylindrical warper factory class.
/// ## See also
/// detail::CylindricalWarper
#[allow(dead_code)]
pub struct CylindricalWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::CylindricalWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_CylindricalWarper_delete(self.ptr) };
    }
}
impl crate::stitching::CylindricalWarper {
    pub fn as_raw_CylindricalWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        CylindricalWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for CylindricalWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl CylindricalWarper {

}

// boxed class cv::FisheyeWarper
#[allow(dead_code)]
pub struct FisheyeWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::FisheyeWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_FisheyeWarper_delete(self.ptr) };
    }
}
impl crate::stitching::FisheyeWarper {
    pub fn as_raw_FisheyeWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        FisheyeWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for FisheyeWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl FisheyeWarper {

}

// boxed class cv::MercatorWarper
#[allow(dead_code)]
pub struct MercatorWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::MercatorWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_MercatorWarper_delete(self.ptr) };
    }
}
impl crate::stitching::MercatorWarper {
    pub fn as_raw_MercatorWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        MercatorWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for MercatorWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl MercatorWarper {

}

// boxed class cv::PaniniPortraitWarper
#[allow(dead_code)]
pub struct PaniniPortraitWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::PaniniPortraitWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_PaniniPortraitWarper_delete(self.ptr) };
    }
}
impl crate::stitching::PaniniPortraitWarper {
    pub fn as_raw_PaniniPortraitWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        PaniniPortraitWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for PaniniPortraitWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl PaniniPortraitWarper {

    ///
    /// ## C++ default parameters
    /// * a: 1
    /// * b: 1
    pub fn new(a: f32, b: f32) -> Result<crate::stitching::PaniniPortraitWarper> {
        unsafe { sys::cv_PaniniPortraitWarper_PaniniPortraitWarper_float_float(a, b) }.into_result().map(|x| crate::stitching::PaniniPortraitWarper { ptr: x })
    }
    
}

// boxed class cv::PaniniWarper
#[allow(dead_code)]
pub struct PaniniWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::PaniniWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_PaniniWarper_delete(self.ptr) };
    }
}
impl crate::stitching::PaniniWarper {
    pub fn as_raw_PaniniWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        PaniniWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for PaniniWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl PaniniWarper {

    ///
    /// ## C++ default parameters
    /// * a: 1
    /// * b: 1
    pub fn new(a: f32, b: f32) -> Result<crate::stitching::PaniniWarper> {
        unsafe { sys::cv_PaniniWarper_PaniniWarper_float_float(a, b) }.into_result().map(|x| crate::stitching::PaniniWarper { ptr: x })
    }
    
}

// boxed class cv::PlaneWarper
/// Plane warper factory class.
/// ## See also
/// detail::PlaneWarper
#[allow(dead_code)]
pub struct PlaneWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::PlaneWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_PlaneWarper_delete(self.ptr) };
    }
}
impl crate::stitching::PlaneWarper {
    pub fn as_raw_PlaneWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        PlaneWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for PlaneWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl PlaneWarper {

}

// boxed class cv::SphericalWarper
/// Spherical warper factory class
#[allow(dead_code)]
pub struct SphericalWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::SphericalWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_SphericalWarper_delete(self.ptr) };
    }
}
impl crate::stitching::SphericalWarper {
    pub fn as_raw_SphericalWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        SphericalWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for SphericalWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl SphericalWarper {

}

// boxed class cv::StereographicWarper
#[allow(dead_code)]
pub struct StereographicWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::StereographicWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_StereographicWarper_delete(self.ptr) };
    }
}
impl crate::stitching::StereographicWarper {
    pub fn as_raw_StereographicWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        StereographicWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for StereographicWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl StereographicWarper {

}

// boxed class cv::Stitcher
/// High level image stitcher.
/// 
/// It's possible to use this class without being aware of the entire stitching pipeline. However, to
/// be able to achieve higher stitching stability and quality of the final images at least being
/// familiar with the theory is recommended.
/// 
/// 
/// Note:
/// *   A basic example on image stitching can be found at
/// opencv_source_code/samples/cpp/stitching.cpp
/// *   A detailed example on image stitching can be found at
/// opencv_source_code/samples/cpp/stitching_detailed.cpp
#[allow(dead_code)]
pub struct Stitcher {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::Stitcher {
    fn drop(&mut self) {
        unsafe { sys::cv_Stitcher_delete(self.ptr) };
    }
}
impl crate::stitching::Stitcher {
    pub fn as_raw_Stitcher(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        Stitcher {
            ptr
        }
    }
}

impl Stitcher {

    /// Creates a stitcher with the default parameters.
    /// 
    /// ## Parameters
    /// * try_use_gpu: Flag indicating whether GPU should be used whenever it's possible.
    /// ## Returns
    /// Stitcher class instance.
    ///
    /// ## C++ default parameters
    /// * try_use_gpu: false
    pub fn create_default(try_use_gpu: bool) -> Result<crate::stitching::Stitcher> {
        unsafe { sys::cv_Stitcher_createDefault_bool(try_use_gpu) }.into_result().map(|x| crate::stitching::Stitcher { ptr: x })
    }
    
    pub fn registration_resol(&self) -> Result<f64> {
        unsafe { sys::cv_Stitcher_registrationResol_const(self.as_raw_Stitcher()) }.into_result()
    }
    
    pub fn set_registration_resol(&mut self, resol_mpx: f64) -> Result<()> {
        unsafe { sys::cv_Stitcher_setRegistrationResol_double(self.as_raw_Stitcher(), resol_mpx) }.into_result()
    }
    
    pub fn seam_estimation_resol(&self) -> Result<f64> {
        unsafe { sys::cv_Stitcher_seamEstimationResol_const(self.as_raw_Stitcher()) }.into_result()
    }
    
    pub fn set_seam_estimation_resol(&mut self, resol_mpx: f64) -> Result<()> {
        unsafe { sys::cv_Stitcher_setSeamEstimationResol_double(self.as_raw_Stitcher(), resol_mpx) }.into_result()
    }
    
    pub fn compositing_resol(&self) -> Result<f64> {
        unsafe { sys::cv_Stitcher_compositingResol_const(self.as_raw_Stitcher()) }.into_result()
    }
    
    pub fn set_compositing_resol(&mut self, resol_mpx: f64) -> Result<()> {
        unsafe { sys::cv_Stitcher_setCompositingResol_double(self.as_raw_Stitcher(), resol_mpx) }.into_result()
    }
    
    pub fn pano_confidence_thresh(&self) -> Result<f64> {
        unsafe { sys::cv_Stitcher_panoConfidenceThresh_const(self.as_raw_Stitcher()) }.into_result()
    }
    
    pub fn set_pano_confidence_thresh(&mut self, conf_thresh: f64) -> Result<()> {
        unsafe { sys::cv_Stitcher_setPanoConfidenceThresh_double(self.as_raw_Stitcher(), conf_thresh) }.into_result()
    }
    
    pub fn wave_correction(&self) -> Result<bool> {
        unsafe { sys::cv_Stitcher_waveCorrection_const(self.as_raw_Stitcher()) }.into_result()
    }
    
    pub fn set_wave_correction(&mut self, flag: bool) -> Result<()> {
        unsafe { sys::cv_Stitcher_setWaveCorrection_bool(self.as_raw_Stitcher(), flag) }.into_result()
    }
    
    pub fn component(&self) -> Result<types::VectorOfint> {
        unsafe { sys::cv_Stitcher_component_const(self.as_raw_Stitcher()) }.into_result().map(|x| types::VectorOfint { ptr: x })
    }
    
    pub fn work_scale(&self) -> Result<f64> {
        unsafe { sys::cv_Stitcher_workScale_const(self.as_raw_Stitcher()) }.into_result()
    }
    
}

// boxed class cv::TransverseMercatorWarper
#[allow(dead_code)]
pub struct TransverseMercatorWarper {
    #[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::stitching::TransverseMercatorWarper {
    fn drop(&mut self) {
        unsafe { sys::cv_TransverseMercatorWarper_delete(self.ptr) };
    }
}
impl crate::stitching::TransverseMercatorWarper {
    pub fn as_raw_TransverseMercatorWarper(&self) -> *mut c_void { self.ptr }
    pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
        TransverseMercatorWarper {
            ptr
        }
    }
}

impl crate::stitching::WarperCreator for TransverseMercatorWarper {
    fn as_raw_WarperCreator(&self) -> *mut c_void { self.ptr }
}

impl TransverseMercatorWarper {

}

// Generating impl for trait cv::WarperCreator (trait)
/// Image warper factories base class.
pub trait WarperCreator {
    #[doc(hidden)] fn as_raw_WarperCreator(&self) -> *mut c_void;
}

impl<'a> WarperCreator + 'a {

}