In the process of extracting watermark, some problems are encountered.
First of all, according to the ideas in the paper to comb the entire extraction process
- Read into two models, a primitive model Ori_mesh, a watermark model Wm_mesh.
- Align two models (that is, in the same coordinate system)
- The spectral coefficients of two models were calculated, the spectral coefficients of Ori_mesh were RS, Rt, Ru, Wm_mesh, and the spectral coefficients of WRs, WRt and WRU were recorded.
- Calculate QJ According to the following formula
- According to the following formula to calculate the embedded watermark symbol, here is equivalent to get embedded watermark B ', just remember that AJ
- Finally, the original watermark sequence B is obtained according to the following formula
?
Based on the above steps, I started with the idea of reading two models under the grid platform, and then doing the calculations in the above steps would be a bit of a hassle, such as getting a grid, although you can use a linked list to store open files, but when initializing the grid, because the parameters are separate, If it's all rewritten as an array or a linked list, it can be quite cumbersome to change. So I decided to embed the watermark when the R matrix is written to the file, so that when the watermark is not read into the original grid, just calculate the read into the watermark grid in the WR matrix, and then read out the R matrix from the file, the difference between the two, and then the original steps to Judge .
?
The write and read are as follows:
//write the spectral coefficients of the original mesh to the file Rs????????
Ofstream Rsfile;
???????? rsfile. Open ("D:\\rs.txt",ios_base:: out);
???????? if ( rsfile)
???????? {
???????????? for ( inti = 0; I < m_vertexnum; I+ +)
???????????? {
???????????? rsfile<<Rs[i]<<"";
????????????}
????????}
???????? rsfile. Close ();
?
???? Read the spectral coefficients of the original mesh from the file
???????? Double *pRs = newdouble[m_vertexnum];
???????? Double *pRt = newdouble[m_vertexnum];
???????? Double *pRu = newdouble[m_vertexnum];
?
???????? //rs
???????? Ifstream Rsfile;
???????? rsfile. Open ("D:\\rs.txt",ios_base:: in);
???????? if (rsfile)
???????? {
???????????? //Read into memory
???????????? rsfile. SEEKG (0, rsfile. end);
???????????? int length = rsfile. Tellg ();
???????????? rsfile. SEEKG (0, rsfile. Beg);
?
???????????? Char *buffer = newchar[length];
???????????? rsfile. Read (buffer, length);
???????????? rsfile. Close ();
?
???????????? //Parse into array
???????????? std::istringstreamISS(buffer);
???????????? int I = 0;
???????????? while (ISS >> pRs[i+ +]);
???????????? Delete [] buffer;
???????????? //print or use it.
????????}
???????? rsfile. Close ();
In the process of extraction, the main problem is on the sign function, because not find the sign function belongs to the header file, so I myself implemented a sign function, the code is as follows:
Double eigendeformation::sign ( doublex)
???? {
???????? cout <<"x ="<< x <<Endl;
???????? if ( x > 0)
???????????? return 1;
???????? Else if (fabs(x) < 0.000000000001)
???????????? return 0;
???????? Else
???????????? return -1;
????}
Because of the accuracy of the relationship, the sign function determines that the symbol is always incorrect, debug view the value of the input sign function and its output only as follows:
where x is the input value, p is the value that is obtained after the judgment.
Then common sense will be the input to enlarge 1kw times also failed.
use a different function instead ? double _copysign (double x, double y);
This function is a function of math.h in C, function: Return the first parameter x with the sign of the second parameter Y (positive or negative), and call the form in the code as follows:
WB [i] = _copysign(1, Q[i]);
The results are as follows:
The return symbol succeeds, comparing the embedded watermark sequence
How do the two differ so much ...
The results of P are the same each time they are run.
?
?
Error 1: When the RT is read into the file, it is written in Rs.
Error 2: Vertex Assignment method Error
Correct:
R of the original grid R watermark Grid
?
C + + implementation of Grid watermark Debug Note (v)--extraction error