기본 콘텐츠로 건너뛰기

C++ - int[] to SafeArray 변환 테스트

 int getPerspectiveTransform(char* src_img_file, char* dst_img_file)

{

int result;

const int nPoints = 8;

_bstr_t src_img_file2(src_img_file);

_bstr_t dst_img_file2(dst_img_file);


int src_pts[8] = { 10, 25, 120, 790, 2200, 750, 2275, 10 };

int dst_pts[8] = { 10, 25, 10, 790, 2275, 790, 2275, 25 };


SAFEARRAY* output;

SAFEARRAYBOUND BoundOutput;

BoundOutput.cElements = nPoints;

BoundOutput.lLbound = 0;

output = SafeArrayCreate(VT_I4, 1, &BoundOutput);


int* pdata1;

SafeArrayAccessData(output, (void**)&pdata1);

for (int i = 0; i < nPoints; i++)

pdata1[i] = src_pts[i];

SafeArrayUnaccessData(output);


SAFEARRAY* output2;

SAFEARRAYBOUND BoundOutput2;

BoundOutput2.cElements = nPoints;

BoundOutput2.lLbound = 0;

output2 = SafeArrayCreate(VT_I4, 1, &BoundOutput2);


int* pdata2;

SafeArrayAccessData(output2, (void**)&pdata2);

for (int i = 0; i < nPoints; i++)

pdata2[i] = dst_pts[i];

SafeArrayUnaccessData(output2);


OpenCVInterface* ocv = NULL;

CoInitialize(NULL);

HRESULT hr = CoCreateInstance(CLSID_OpenCV, NULL, CLSCTX_INPROC_SERVER, IID_OpenCVInterface, reinterpret_cast<void**>(&ocv));

if (SUCCEEDED(hr))

{

result = ocv->getPerspectiveTransform(src_img_file2, dst_img_file2, output, output2);

result = 1;

}

else

result = 0;

return result;

}

댓글

이 블로그의 인기 게시물

C# - Serial Port ASCII/HEX Format

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO.Ports; namespace SerialTest1 {     public partial class Form1 : Form     {         delegate void MyDelegate();      //델리게이트 선언(크로스 쓰레드 해결하기 위한 용도)         bool SendForamt = true;          // true : ASCII   false : HEX         bool ReceiveFormat = true;       // true : ASCII   false : HEX         public Form1()         {             InitializeComponent();          ...

C# - Windows Form 에 있는 control 찾기

// 아래 코드는 form 의 최상위 control만 찾을 수 있음. // panle, groubbox ... 내부에 있는 control은 찾지 못함. Control GetControlByName(string Name) {     foreach (Control c in this.Controls)         if (c.Name == Name)             return c;     return null; } // form 의 모든 control을 찾을 수 있음. string name = "btnBit" + (i + 1).ToString("D2"); var tmpBtn = this.Controls.Find(name, true).FirstOrDefault(); if (tmpBtn != null) {     if (value == 1) tmpBtn.BackColor = Color.Lime;     else tmpBtn.BackColor = Color.Gray; }