Jrepl
Moderator: DosItHelp
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
Hi,
Just from "Person1" and "Person2" tags. "Person3" and "Person4" does not exist.
I need a separate batch code. Thank you!
Kind regards,
Dan
Just from "Person1" and "Person2" tags. "Person3" and "Person4" does not exist.
I need a separate batch code. Thank you!
Kind regards,
Dan
Re: Jrepl
mogodan2008 wrote:Just from "Person1" and "Person2" tags. "Person3" and "Person4" does not exist.
That's what I already understood. But what value for what eye lid comes from what person?
mogodan2008 wrote:I need a separate batch code.
No you don't. The code checks the number of person nodes.
Steffen
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
Hi,
I have the another xml files like this:
<?xml version='1.0' encoding='UTF-8'?>
<image id="21653333" version="1.0" image-url="J:\23.06.2017 855 1-5\TagImage-DMS_NIR-Cam-Gen1_Phase2_John_Optitrack-Blink_20160218-150629_30.bw_640x48030fps\21653200.png" width="640" height="480" importedBy="fortune" modifiedBy="fortune" mime-type="image/png">
<creator>Ted</creator>
<rights>Copyright 2016</rights>
<filename>00000353.png</filename>
<created>1456161075163</created>
<lastmodified>1498823619323</lastmodified>
<tag name="DMS_NIR-Cam-Gen1_Phase2_Dan-East_Optitrack-Blink_20160218-150629_30.bw_640x480@30fps"/>
<pfml version="1.0">
<face>
<attribute name="translation-v-mm">-14.50</attribute>
<attribute name="face-roll-deg">-2.92</attribute>
<attribute name="3d-orientation-pitch">-0.82</attribute>
<attribute name="3d-orientation-qz">0.0174208917</attribute>
<attribute name="3d-orientation-qy">-0.5430638790</attribute>
<attribute name="3d-orientation-qx">0.0197824873</attribute>
<attribute name="translation-h-mm">-127.52</attribute>
<attribute name="3d-orientation-qw">-0.8392775655</attribute>
<attribute name="face-pitch-deg">-2.17</attribute>
<attribute name="3d-orientation-roll">-2.91</attribute>
<attribute name="translation-z-mm">779.35</attribute>
<attribute name="face-yaw-deg">73.30</attribute>
<attribute name="3d-orientation-yaw">65.83</attribute>
<geometry>
<Rectangle x="344" y="219" width="112" height="145"/>
</geometry>
<eye>
<eye-bounds>
<attribute name="3d-position-z">814.32</attribute>
<attribute name="3d-position-y">-12.65</attribute>
<attribute name="3d-position-x">-130.09</attribute>
<attribute name="open-closed-state">open</attribute>
<geometry>
<Rectangle x="411" y="250" width="9" height="11"/>
</geometry>
</eye-bounds>
<lower-eyelid>
<geometry>
<Point x="411.35" y="257.11"/>
</geometry>
</lower-eyelid>
<upper-eyelid>
<geometry>
<Point x="411.62" y="247.02"/>
</geometry>
</upper-eyelid>
</eye>
<eye markedPos="1">
<eye-bounds>
<attribute name="3d-position-z">754.20</attribute>
<attribute name="3d-position-y">-16.00</attribute>
<attribute name="3d-position-x">-103.06</attribute>
<attribute name="occlusion">hidden</attribute>
<attribute name="open-closed-state">open</attribute>
<geometry>
<Rectangle x="427" y="244" width="8" height="12"/>
</geometry>
</eye-bounds>
</eye>
<mouth>
<geometry>
<Rectangle x="428" y="309" width="12" height="12"/>
</geometry>
</mouth>
</face>
<person>
<attribute name="personName">Person1</attribute>
<geometry>
<Rectangle x="414.2" y="256.65" width="5.08" height="5.08"/>
</geometry>
</person>
<person>
<attribute name="personName">Person2</attribute>
<geometry>
<Rectangle x="413.9" y="247.53" width="5.08" height="5.08"/>
</geometry>
</person>
</pfml>
<orig-lastmodified>1497878179194</orig-lastmodified>
</image>
I need to replace the x, y values of lower-eyelid with x, y values of Person1 and the x, y values of upper-eyelid with x, y values of Person2. Thank you!
I have the another xml files like this:
<?xml version='1.0' encoding='UTF-8'?>
<image id="21653333" version="1.0" image-url="J:\23.06.2017 855 1-5\TagImage-DMS_NIR-Cam-Gen1_Phase2_John_Optitrack-Blink_20160218-150629_30.bw_640x48030fps\21653200.png" width="640" height="480" importedBy="fortune" modifiedBy="fortune" mime-type="image/png">
<creator>Ted</creator>
<rights>Copyright 2016</rights>
<filename>00000353.png</filename>
<created>1456161075163</created>
<lastmodified>1498823619323</lastmodified>
<tag name="DMS_NIR-Cam-Gen1_Phase2_Dan-East_Optitrack-Blink_20160218-150629_30.bw_640x480@30fps"/>
<pfml version="1.0">
<face>
<attribute name="translation-v-mm">-14.50</attribute>
<attribute name="face-roll-deg">-2.92</attribute>
<attribute name="3d-orientation-pitch">-0.82</attribute>
<attribute name="3d-orientation-qz">0.0174208917</attribute>
<attribute name="3d-orientation-qy">-0.5430638790</attribute>
<attribute name="3d-orientation-qx">0.0197824873</attribute>
<attribute name="translation-h-mm">-127.52</attribute>
<attribute name="3d-orientation-qw">-0.8392775655</attribute>
<attribute name="face-pitch-deg">-2.17</attribute>
<attribute name="3d-orientation-roll">-2.91</attribute>
<attribute name="translation-z-mm">779.35</attribute>
<attribute name="face-yaw-deg">73.30</attribute>
<attribute name="3d-orientation-yaw">65.83</attribute>
<geometry>
<Rectangle x="344" y="219" width="112" height="145"/>
</geometry>
<eye>
<eye-bounds>
<attribute name="3d-position-z">814.32</attribute>
<attribute name="3d-position-y">-12.65</attribute>
<attribute name="3d-position-x">-130.09</attribute>
<attribute name="open-closed-state">open</attribute>
<geometry>
<Rectangle x="411" y="250" width="9" height="11"/>
</geometry>
</eye-bounds>
<lower-eyelid>
<geometry>
<Point x="411.35" y="257.11"/>
</geometry>
</lower-eyelid>
<upper-eyelid>
<geometry>
<Point x="411.62" y="247.02"/>
</geometry>
</upper-eyelid>
</eye>
<eye markedPos="1">
<eye-bounds>
<attribute name="3d-position-z">754.20</attribute>
<attribute name="3d-position-y">-16.00</attribute>
<attribute name="3d-position-x">-103.06</attribute>
<attribute name="occlusion">hidden</attribute>
<attribute name="open-closed-state">open</attribute>
<geometry>
<Rectangle x="427" y="244" width="8" height="12"/>
</geometry>
</eye-bounds>
</eye>
<mouth>
<geometry>
<Rectangle x="428" y="309" width="12" height="12"/>
</geometry>
</mouth>
</face>
<person>
<attribute name="personName">Person1</attribute>
<geometry>
<Rectangle x="414.2" y="256.65" width="5.08" height="5.08"/>
</geometry>
</person>
<person>
<attribute name="personName">Person2</attribute>
<geometry>
<Rectangle x="413.9" y="247.53" width="5.08" height="5.08"/>
</geometry>
</person>
</pfml>
<orig-lastmodified>1497878179194</orig-lastmodified>
</image>
I need to replace the x, y values of lower-eyelid with x, y values of Person1 and the x, y values of upper-eyelid with x, y values of Person2. Thank you!
Re: Jrepl
So only the first eye node has lower-eyelid and upper-eyelid child nodes. Correct?
Steffen
Steffen
- Attachments
-
- change_xml.zip
- (986 Bytes) Downloaded 587 times
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
Not realy, could be a xml file with the second eye node with lower-eyelid and upper-eyelied. It doesn't matter what eye-bound it reffer, because lower-eyelid and upper-eyelid will be allways in the correct eye-bound. So, I need just replace the x, y values. Thank you!
Dan
Dan
Re: Jrepl
What an inconsistent mess
Another attempt ... If this doesn't work properly please try to list all of the exceptions and special cases.
Steffen

Another attempt ... If this doesn't work properly please try to list all of the exceptions and special cases.
Steffen
- Attachments
-
- change_xml.zip
- (1.06 KiB) Downloaded 626 times
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
I know Steffen...
The code is working, except the last " if ".
Dan
The code is working, except the last " if ".
Dan
Re: Jrepl
There was a typo in the assignment of variable upperLid2. Please try the attached script.
Steffen
Steffen
- Attachments
-
- change_xml.zip
- (1.06 KiB) Downloaded 763 times
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
Hi Steffen,
You are great! The code is working very well.
I appreciate your help, thank you!
Best regards,
Dan
You are great! The code is working very well.
I appreciate your help, thank you!
Best regards,
Dan
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
Hi Steffen,
I wonder if you can help me. Based on xml files involved, and your code, I tried to write a code, to copy xml files from a location to another location:
"
@if (@a)==(@b) @end /*
:: Batch
@echo off &setlocal
set /a "start=21653196, stop=21653200"
for /l %%i in (%start% 1 %stop%) do (
if exist "%%i.xml" (
cscript //nologo //e:jscript "%~fs0" "%%i.xml"
) else (
echo "%%i.xml" not found
)
)
pause
:: JScript
exit /b&::*/ try {
var xmlFileName = WScript.Arguments(0);
oXmlDoc = new ActiveXObject('Microsoft.XMLDOM');
oXmlDoc.load(xmlFileName);
var colEyeNodes = oXmlDoc.documentElement.getElementsByTagName('eye'),
if (colEyeNodes.length === 2) {
var arrEyeBoundX = new Array(parseFloat(colEyeNodes.item(0).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x')),
parseFloat(colEyeNodes.item(1).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x'))),
if (arrEyeBoundX[0] < arrEyeBoundX[1]) {
var fs = require('fs');
fs.createReadStream('%%i.xml').pipe(fs.createWriteStream('C:\Test\Test1\%%i.xml'));
} else {
var fs = require('fs');
fs.createReadStream('%%i.xml').pipe(fs.createWriteStream('C:\Test\Test2\%%i.xml'));
}
oXmlDoc.save(xmlFileName);
WScript.Quit(0);
} else {
WScript.StdErr.WriteLine('Wrong number of either "eye" nodes.');
WScript.Quit(1);
}
}
catch(e) {
WScript.StdErr.WriteLine(e.message);
WScript.Quit(1);
}
"
So, basically, If the x point of first eye-bound is < x point of second eye-bounds, copy the xml file from current location to one location, otherwise copy xml file to another location.
I run the code above, but the cmd window show me the message: "Microsoft JScript compilation error: Expected identifier"
Please, can you help me?
Kind regards,
Dan
I wonder if you can help me. Based on xml files involved, and your code, I tried to write a code, to copy xml files from a location to another location:
"
@if (@a)==(@b) @end /*
:: Batch
@echo off &setlocal
set /a "start=21653196, stop=21653200"
for /l %%i in (%start% 1 %stop%) do (
if exist "%%i.xml" (
cscript //nologo //e:jscript "%~fs0" "%%i.xml"
) else (
echo "%%i.xml" not found
)
)
pause
:: JScript
exit /b&::*/ try {
var xmlFileName = WScript.Arguments(0);
oXmlDoc = new ActiveXObject('Microsoft.XMLDOM');
oXmlDoc.load(xmlFileName);
var colEyeNodes = oXmlDoc.documentElement.getElementsByTagName('eye'),
if (colEyeNodes.length === 2) {
var arrEyeBoundX = new Array(parseFloat(colEyeNodes.item(0).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x')),
parseFloat(colEyeNodes.item(1).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x'))),
if (arrEyeBoundX[0] < arrEyeBoundX[1]) {
var fs = require('fs');
fs.createReadStream('%%i.xml').pipe(fs.createWriteStream('C:\Test\Test1\%%i.xml'));
} else {
var fs = require('fs');
fs.createReadStream('%%i.xml').pipe(fs.createWriteStream('C:\Test\Test2\%%i.xml'));
}
oXmlDoc.save(xmlFileName);
WScript.Quit(0);
} else {
WScript.StdErr.WriteLine('Wrong number of either "eye" nodes.');
WScript.Quit(1);
}
}
catch(e) {
WScript.StdErr.WriteLine(e.message);
WScript.Quit(1);
}
"
So, basically, If the x point of first eye-bound is < x point of second eye-bounds, copy the xml file from current location to one location, otherwise copy xml file to another location.
I run the code above, but the cmd window show me the message: "Microsoft JScript compilation error: Expected identifier"
Please, can you help me?
Kind regards,
Dan
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
Hi Steffen,
I have corrected the code above, and the result is:
@if (@a)==(@b) @end /*
:: Batch
@echo off &setlocal
set /a "start=21656152, stop=21656156"
for /l %%i in (%start% 1 %stop%) do (
if exist "%%i.xml" (
cscript //nologo //e:jscript "%~fs0" "%%i.xml"
) else (
echo "%%i.xml" not found
)
)
pause
:: JScript
exit /b&::*/ try {
var xmlFileName = WScript.Arguments(0);
oXmlDoc = new ActiveXObject('Microsoft.XMLDOM');
oXmlDoc.load(xmlFileName);
var colEyeNodes = oXmlDoc.documentElement.getElementsByTagName('eye');
if (colEyeNodes.length === 2) {
var arrEyeBoundX = new Array(parseFloat(colEyeNodes.item(0).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x')),
parseFloat(colEyeNodes.item(1).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x')));
if (arrEyeBoundX[0] < arrEyeBoundX[1]) {
var fs = require('fs');
fs.createReadStream('C:\\Users\\Dan\\Desktop\\Temp\\Prelucrate\\xmlFileName').pipe(fs.createWriteStream('C:\\Test\\Test1\\'));
} else {
var fs = require('fs');
fs.createReadStream('C:\\Users\\Dan\\Desktop\\Temp\\Prelucrate\\xmlFileName').pipe(fs.createWriteStream('C:\\Test\\Test2\\'));
}
oXmlDoc.save(xmlFileName);
WScript.Quit(0);
} else {
WScript.StdErr.WriteLine('Wrong number of either "eye" nodes.');
WScript.Quit(1);
}
}
catch(e) {
WScript.StdErr.WriteLine(e.message);
WScript.Quit(1);
}
But, when I run the bat file, the cmd windows show: " Object expected Press any key to continue..."
Could you tell me what I'm doing wrong, please?
Best regards,
Dan
I have corrected the code above, and the result is:
@if (@a)==(@b) @end /*
:: Batch
@echo off &setlocal
set /a "start=21656152, stop=21656156"
for /l %%i in (%start% 1 %stop%) do (
if exist "%%i.xml" (
cscript //nologo //e:jscript "%~fs0" "%%i.xml"
) else (
echo "%%i.xml" not found
)
)
pause
:: JScript
exit /b&::*/ try {
var xmlFileName = WScript.Arguments(0);
oXmlDoc = new ActiveXObject('Microsoft.XMLDOM');
oXmlDoc.load(xmlFileName);
var colEyeNodes = oXmlDoc.documentElement.getElementsByTagName('eye');
if (colEyeNodes.length === 2) {
var arrEyeBoundX = new Array(parseFloat(colEyeNodes.item(0).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x')),
parseFloat(colEyeNodes.item(1).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x')));
if (arrEyeBoundX[0] < arrEyeBoundX[1]) {
var fs = require('fs');
fs.createReadStream('C:\\Users\\Dan\\Desktop\\Temp\\Prelucrate\\xmlFileName').pipe(fs.createWriteStream('C:\\Test\\Test1\\'));
} else {
var fs = require('fs');
fs.createReadStream('C:\\Users\\Dan\\Desktop\\Temp\\Prelucrate\\xmlFileName').pipe(fs.createWriteStream('C:\\Test\\Test2\\'));
}
oXmlDoc.save(xmlFileName);
WScript.Quit(0);
} else {
WScript.StdErr.WriteLine('Wrong number of either "eye" nodes.');
WScript.Quit(1);
}
}
catch(e) {
WScript.StdErr.WriteLine(e.message);
WScript.Quit(1);
}
But, when I run the bat file, the cmd windows show: " Object expected Press any key to continue..."
Could you tell me what I'm doing wrong, please?
Best regards,
Dan
Re: Jrepl
Untested:
Note that the 2 destination folders are now additional arguments for the cscript command line.
Steffen
Code: Select all
@if (@a)==(@b) @end /*
:: Batch
@echo off &setlocal
set /a "start=21653196, stop=21653200"
for /l %%i in (%start% 1 %stop%) do (
if exist "%%i.xml" (
cscript //nologo //e:jscript "%~fs0" "%%i.xml" "C:\Test\Test1" "C:\Test\Test2"
) else (
echo "%%i.xml" not found
)
)
pause
:: JScript
exit /b&::*/ try {
var xmlFileName = WScript.Arguments(0);
oXmlDoc = new ActiveXObject('Microsoft.XMLDOM');
oXmlDoc.load(xmlFileName);
var colEyeNodes = oXmlDoc.documentElement.getElementsByTagName('eye');
if (colEyeNodes.length === 2) {
var oFSO = new ActiveXObject('Scripting.FileSystemObject'),
arrEyeBoundX = new Array(parseFloat(colEyeNodes.item(0).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x')),
parseFloat(colEyeNodes.item(1).selectSingleNode('eye-bounds/geometry/Rectangle').getAttribute('x')));
if (arrEyeBoundX[0] < arrEyeBoundX[1]) {
oFSO.CopyFile(xmlFileName, oFSO.BuildPath(WScript.Arguments(1), xmlFileName), true);
} else {
oFSO.CopyFile(xmlFileName, oFSO.BuildPath(WScript.Arguments(2), xmlFileName), true);
}
WScript.Quit(0);
} else {
WScript.StdErr.WriteLine('Wrong number of "eye" nodes.');
WScript.Quit(1);
}
}
catch(e) {
WScript.StdErr.WriteLine(e.message);
WScript.Quit(1);
}
Note that the 2 destination folders are now additional arguments for the cscript command line.
Steffen
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
Hi Steffen,
I run the code, but the windows cmd show: "else was unexpected at this time."
Best regards,
Dan
I run the code, but the windows cmd show: "else was unexpected at this time."
Best regards,
Dan
Re: Jrepl
I don't see any reason for this failure. I tested the code now and it works for me. Maybe I have to attach the script again. For whatever reason it seems you did someting wrong when you c/p the code.
Steffen
Steffen
- Attachments
-
- copyXML.zip
- (741 Bytes) Downloaded 721 times
-
- Posts: 17
- Joined: 25 Jun 2017 02:37
Re: Jrepl
Hi Steffen,
The code is working great! I do apreciate your work. Thank you!
Best regards,
Dan
The code is working great! I do apreciate your work. Thank you!
Best regards,
Dan