Delphi-OpenCV/2.4.3/samples/XML/XML.dpr

116 lines
2.6 KiB
ObjectPascal
Raw Normal View History

program XML;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Core.types_c in '..\..\include\<5C>ore\Core.types_c.pas',
core_c in '..\..\include\<5C>ore\core_c.pas',
highgui_c in '..\..\include\highgui\highgui_c.pas';
Var
kernel: array [0 .. 8] of Single;
kernel_matrix: TCvMat;
i: Integer;
j: Integer;
matrix: pCvMat;
begin
try
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
kernel[0] := 1;
kernel[1] := 0;
kernel[2] := 0;
kernel[3] := 0;
kernel[4] := 2;
kernel[5] := 0;
kernel[6] := 0;
kernel[7] := 0;
kernel[8] := 3;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
kernel_matrix := cvMat(3, 3, CV_32FC1, @kernel);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> XML-<2D><><EFBFBD><EFBFBD>
cvSave('kernel.xml', @kernel_matrix);
// <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> XML-<2D><><EFBFBD><EFBFBD><EFBFBD>
matrix := pCvMat(cvLoad('kernel.xml'));
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CV_MAT_ELEM
for i := 0 to matrix^.rows - 1 do
begin
for j := 0 to matrix^.cols - 1 do
Write(Format('%.0f ', [Single(CV_MAT_ELEM(matrix^, CV_32FC1, i, j)^)]));
Writeln;
end;
Writeln;
// // 2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cvGet2D(), cvGetReal2D()
// for (i = 0; i < matrix - > rows; i + +) {
// for(j=0; j<matrix->cols; j++){
// printf("%.0f ", cvGet2D(matrix, i, j));//cvGetReal2D(matrix, i, j));
// }
// printf(" \ n ");
// } printf(" - - - - - \ n ");
//
// // 3 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// for (i = 0; i < matrix - > rows; i + +) {
// float* ptr = (float*)(matrix->data.ptr + i*matrix->step);
// for(j=0; j<matrix->cols; j++){
// printf("%.0f ", ptr[j]);
// }
// printf(" \ n ");
// }
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cvReleaseMat(matrix);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> XML
//printf("Example 3_19 Reading in cfg.xml\n");
//
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// CvFileStorage* fs = cvOpenFileStorage(
// "cfg.xml",
// 0,
// CV_STORAGE_READ
// );
//
// //
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// //
// int frame_count = cvReadIntByName(
// fs,
// 0,
// "frame_count",
// 5 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// );
//
// CvSeq* s = cvGetFileNodeByName(fs,0,"frame_size")->data.seq;
//
// int frame_width = cvReadInt(
// (CvFileNode*)cvGetSeqElem(s,0)
// );
//
// int frame_height = cvReadInt(
// (CvFileNode*)cvGetSeqElem(s,1)
// );
//
// CvMat* color_cvt_matrix = (CvMat*) cvRead(
// fs,
// 0
// );
//
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// printf("frame_count=%d, frame_width=%d, frame_height=%d\n",frame_count,frame_width,frame_height);
//
// cvReleaseFileStorage( &fs );
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.