Очень хочу разобраться (свои размышления сделал в виде комментариев в camera.cpp скорей всего я не прав и хотел бы узнать, как правильно )
Form1.h
- Код: Выделить всё • Развернуть
#include "camera.h"
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include "stdafx.h"
#pragma once
namespace CppCLR_WinformsProjekt {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Zusammenfassung fьr Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Konstruktorcode hier hinzufьgen.
//
// capture = new cv::VideoCapture();
}
protected:
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::PictureBox^ pictureBox1;
protected:
protected:
private: System::Windows::Forms::Button^ button1;
protected:
private:
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Erforderliche Methode fьr die Designerunterstьtzung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geдndert werden.
/// </summary>
void InitializeComponent(void)
{
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->button1 = (gcnew System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->BackColor = System::Drawing::SystemColors::Desktop;
this->pictureBox1->Location = System::Drawing::Point(12, 12);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(511, 440);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
this->pictureBox1->Click += gcnew System::EventHandler(this, &Form1::pictureBox1_Click);
//
// button1
//
this->button1->Location = System::Drawing::Point(561, 43);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(115, 27);
this->button1->TabIndex = 1;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(920, 621);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
private:
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void pictureBox1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Start();
}
};
}
Camera.cpp
- Код: Выделить всё • Развернуть
#include "stdafx.h"
#include "camera.h"
//#include "opencv2/highgui/highgui_c.h"
//#include "include\iANPR.h"
#include <stdio.h>
#include <Windows.h>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <math.h>
#include <stdlib.h>
using namespace cv;
using namespace std;
IplImage* image = 0;
IplImage* image1 = 0;
IplImage* image12 = 0;
IplImage* gray = 0;
IplImage* bin = 0;
IplImage* dst = 0;
IplImage* image44 = 0;
IplImage* templ = 0;
IplImage* templ12 = 0;
IplImage* dst2[4];
IplImage* xit = 0;
IplImage* sr = 0;
int x;
int y;
CvCapture* capture;
bool stop;
void Start()
{
int i = 0;
int counter = 0;
Mat frame, src, src_gray, img;
VideoCapture cap;
cap.open(CV_CAP_ANY);
int deviceID = CV_CAP_ANY;
int apiID = cv::CAP_ANY;
cap.open(deviceID + apiID);
for (;;)
{
cap.read(frame); //Тут получаю кадр из камеры
//pictureBox1->Image = frame; //неудачная попытка
cvtColor(frame, src_gray, CV_BGR2GRAY);
GaussianBlur(src_gray, src_gray, Size(9, 9), 2, 2); //переход к серому
img = src_gray;
IplImage img1((IplImage)src_gray);// не знаю на сколько правильно так делать но это переход к IplImage
//img1 мне надо вывести на форму
//мне кажется что return img1; мог бы мне помочь если бы не было в цикле
}
}
void Stop()
{
stop = true;
}
camera.h
- Код: Выделить всё • Развернуть
#pragma once
void Start();
void Stop();