opencv有基于c语言的教程吗_哪位大神能用c语言 重写opencv 的下面6个函数??或者从源码中整理出来,可以编译,运行??...

展开全部

去git上面看看源码//先说一下这个32313133353236313431303231363533e78988e69d8331333365643639函数吧

//cvNamedWindow

CV_IMPL int cvNamedWindow(const char* name, int flags){

CV_FUNCNAME("cvNamedWindow");

if (!name)CV_ERROR(CV_StsNullPtr, "NULL name");

HighguiBridge::getInstance().namedWindow(name);

return CV_OK;

}

//而它又需要HighhuiBridge这个类,它有个单例工厂方法

HighguiBridge& HighguiBridge::getInstance(){

static HighguiBridge instance;

return instance;

}

//上面2个函数实际调用这2个成员函数

CvWindow* HighguiBridge::namedWindow(cv::String name) {

CvWindow* window = HighguiBridge::getInstance().findWindowByName(name.c_str());

if (!window)window = createWindow(name);

return window;

}

//创建窗口先是查找有没有已有窗口

CvWindow* HighguiBridge::findWindowByName(cv::String name){

auto search = windowsMap->find(name);

if (search != windowsMap->end())return search->second;

return nullptr;

}

//如果没有会用这个函数创建

CvWindow* HighguiBridge::createWindow(cv::String name){

CvWindow* window = new CvWindow(name);

windowsMap->insert(std::pair<:string>(name, window));

return window;

}

//创建窗口是CvWindow类

class CvWindow{

public:

CvWindow(cv::String name, int flag = CV_WINDOW_NORMAL);

~CvWindow();

/** @brief NOTE: prototype.

Should create button if there is no button with this name already.

*/

void createButton(cv::String name);

/** @brief Creates slider if there is no slider with this name already.

The function creates slider if there is no slider with this name already OR resets

provided values for the existing one.

*/

void createSlider(cv::String name, int* val, int count, CvTrackbarCallback2 on_notify, void* userdata);

/** @brief Updates window image.

@param src Image data object reference.

The function updates window image. If argument is null or image control is not found - does nothing.

*/

void updateImage(CvMat* arr);

/** @brief Returns reference to the trackbar(slider) registered within provided window.

@param name Name of the window.

The function returns reference to the trackbar(slider) registered within provided window.

Returns nullptr if trackbar with specified name is not found or window reference is nullptr.

*/

CvTrackbar*     findTrackbarByName(cv::String name);

Page^           getPage();

private:

cv::String name;

// Holds image data in CV format

CvMat* imageData;

// Map of all sliders assigned to this window

std::map<:string>*  sliderMap;

// Window contents holder

Page^ page;

// Image control displayed by this window

Image^ imageControl;

// Container for sliders

Panel^ sliderPanel;

// Container for buttons

// TODO: prototype, not available via API

Panel^ buttonPanel;

// Holds image width to arrange other UI elements.

// Required since imageData->width value gets recalculated when processing

int imageWidth;

// Default markup for the container content allowing for proper components placement

static const Platform::String^ markupContent;

// Default Slider size, fallback solution for unexpected edge cases

static const double sliderDefaultWidth;

};

//CvWindwo构造函数为

CvWindow::CvWindow(cv::String name, int flags) : name(name){

this->page = (Page^)Windows::UI::Xaml::Markup::XamlReader::Load(const_cast<:string>(markupContent));

this->sliderMap = new std::map<:string>();

sliderPanel = (Panel^)page->FindName("cvTrackbar");

imageControl = (Image^)page->FindName("cvImage");

buttonPanel = (Panel^)page->FindName("cvButton");

// Required to adapt controls to the size of the image.

// System calculates image control width first, after that we can

// update other controls

imageControl->Loaded += ref new Windows::UI::Xaml::RoutedEventHandler(

[=](Platform::Object^ sender,

Windows::UI::Xaml::RoutedEventArgs^ e){

// Need to update sliders with appropriate width

for(auto iter=sliderMap->begin();iter!=sliderMap->end();++iter){

iter->second->getSlider()->Width = imageControl->ActualWidth;

}

// Need to update buttons with appropriate width

// TODO: implement when adding buttons

});

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值