CWO++library
0.32
Main Page
Modules
Classes
Files
Examples
File List
All
Classes
Functions
Variables
Groups
src
cwoCV.h
1
// Copyright (C) Tomoyoshi Shimobaba 2011-
2
3
#ifndef _CWO_CV_H
4
#define _CWO_CV_H
5
6
#include "cwo.h"
7
#include <opencv2/opencv.hpp>
8
10
13
class
cwoCV
{
14
public
:
15
//###########################################
19
cwoCV
();
20
~
cwoCV
();
22
24
28
void
ConvToMat
(
CWO
*src, cv::Mat *dst);
29
31
35
void
ConvToCWO
(cv::Mat *src,
CWO
*dst);
36
};
37
38
cwoCV::cwoCV()
39
{
40
}
41
42
cwoCV::~cwoCV()
43
{
44
}
45
46
void
cwoCV::ConvToMat
(
CWO
*src, cv::Mat *dst)
47
{
48
int
Nx=src->
GetNx
();
49
int
Ny=src->
GetNy
();
50
float
* src_p=(
float
*)src->
GetBuffer
();
51
52
dst->create(Ny,Nx,CV_32F);
53
for
(
int
y = 0 ; y <Ny ; ++y ){
54
for
(
int
x = 0 ; x<Nx ; ++x ){
55
float
pix;
56
src->GetPixel(x,y,pix);
57
dst->at<
float
>(y,x) =pix;
58
}
59
}
60
61
}
62
void
cwoCV::ConvToCWO
(cv::Mat *src,
CWO
*dst)
63
{
64
cv::Size size=src->size();
65
int
Nx=size.width;
66
int
Ny=size.height;
67
68
dst->
Create
(Nx,Ny);
69
dst->SetFieldType(
CWO_FLD_INTENSITY
);
70
71
for
(
int
y = 0 ; y <Ny ; ++y ){
72
for
(
int
x = 0 ; x<Nx ; ++x ){
73
float
pix;
74
dst->SetPixel(x,y,src->at<
float
>(y,x));
75
}
76
}
77
78
}
79
80
#endif
Generated on Mon Apr 2 2018 13:35:29 for CWO++library by
1.8.1