FacialRecognition.qml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. import QtQuick
  2. import QtQuick.Controls
  3. import com.InteractiveTask 1.0
  4. Item {
  5. id: facialrecognition
  6. x: 290
  7. y: 130
  8. width: 1600
  9. height: 920
  10. Connections {
  11. target: facialrecognition
  12. onVisibleChanged: {
  13. if (facialrecognition.visible === true)
  14. {
  15. interactiveFace.setCameraImageCallBack(callback_cameraImageGather, null, callback_cameraImageRemain);
  16. interactiveFace.cameraImagePlay();
  17. facialrecognition_text_result.text = "";
  18. }
  19. else
  20. {
  21. interactiveFace.cameraImageStop();
  22. }
  23. }
  24. }
  25. // 重新拍摄
  26. Button {
  27. id: facialrecognition_btn_retake
  28. x: 928
  29. y: 835
  30. width: 192
  31. height: 75
  32. visible: false
  33. background: Rectangle {
  34. color: "#ff9900"
  35. radius: 10
  36. }
  37. text: qsTr("重新拍摄")
  38. font.pixelSize: 30
  39. palette.buttonText: "white" // 设置字体颜色为绿色
  40. Connections {
  41. target: facialrecognition_btn_retake
  42. onClicked: {
  43. facialrecognition_btn_affirm.visible = false;
  44. facialrecognition_btn_retake.visible = false;
  45. interactiveFace.cameraImagePlay();
  46. }
  47. }
  48. }
  49. // 确定
  50. Button {
  51. id: facialrecognition_btn_affirm
  52. x: 1168
  53. y: 835
  54. width: 192
  55. height: 75
  56. visible: false
  57. background: Rectangle {
  58. color: "#ff0000" // 设置背景为透明
  59. radius: 10 // 可选,设置圆角
  60. }
  61. text: qsTr("确定")
  62. font.pixelSize: 30
  63. palette.buttonText: "white" // 设置字体颜色为绿色
  64. Connections {
  65. target: facialrecognition_btn_affirm
  66. onClicked: {
  67. var userFace = setView.userFace;
  68. if (userFace.length > 0)
  69. {
  70. var inText = userFace.length > 0 ? "?recordIds=" : "";
  71. for (var i = 0; i < userFace.length; ++i)
  72. {
  73. inText += userFace[i];
  74. inText += (i !== userFace.length - 1) ? "," : "";
  75. }
  76. interactiveCore.appendTask(
  77. InteractiveTask.TypeHttpPost_deleteSysUserCharacteristicByRecordIds, inText,
  78. (json)=>{
  79. var jsonObjData = JSON.parse(json);
  80. if (jsonObjData.code === 200) {
  81. var taskType = InteractiveTask.TypeHttpPost_insertUserFace;
  82. interactiveCore.appendTask(taskType, "", call_insertUserFace_reply);
  83. facialrecognition_btn_affirm.visible = false;
  84. facialrecognition_btn_retake.visible = false;
  85. }
  86. else
  87. {
  88. infoPromptBox.title("人脸特征删除失败");
  89. infoPromptBox.message(jsonObjData.msg);
  90. infoPromptBox.button_clear();
  91. infoPromptBox.button_push("#055eb3", "确定", null, null);
  92. infoPromptBox.show();
  93. }
  94. });
  95. }
  96. else
  97. {
  98. var taskType = InteractiveTask.TypeHttpPost_insertUserFace;
  99. interactiveCore.appendTask(taskType, "", call_insertUserFace_reply);
  100. facialrecognition_btn_affirm.visible = false;
  101. facialrecognition_btn_retake.visible = false;
  102. }
  103. }
  104. }
  105. }
  106. // 返回按钮
  107. Button {
  108. id: facialrecognition_btn_return
  109. x: 1408
  110. y: 835
  111. width: 192
  112. height: 75
  113. background: Rectangle {
  114. color: "#055eb3" // 设置背景为透明
  115. radius: 10 // 可选,设置圆角
  116. }
  117. text: qsTr("返回")
  118. font.pixelSize: 30
  119. palette.buttonText: "white" // 设置字体颜色为绿色
  120. Connections {
  121. target: facialrecognition_btn_return
  122. onClicked: {
  123. facialrecognition_btn_affirm.visible = false;
  124. facialrecognition_btn_retake.visible = false;
  125. facialrecognition.visible = false
  126. setView.visible = true;
  127. }
  128. }
  129. }
  130. Rectangle {
  131. id: facialrecognition_rect
  132. width: 1600
  133. height: 800
  134. color: "#272b7ae9"
  135. radius: 20
  136. clip: true
  137. Rectangle {
  138. x: 0
  139. y: 0
  140. width: 1600
  141. height: 800
  142. color: "#000000"
  143. border.color: "#47bfff"
  144. Image {
  145. id: facialrecognition_image_facial
  146. anchors.fill: parent
  147. visible: true
  148. layer.smooth: true
  149. layer.enabled: true
  150. cache: false
  151. fillMode: Image.PreserveAspectFit
  152. }
  153. }
  154. }
  155. Rectangle {
  156. id: delaymatrailstocknotice
  157. x: 0
  158. y: 823
  159. width: 300
  160. height: 75 // 减去顶部圆角矩形的高度
  161. color: "#00ffffff"
  162. visible: true
  163. // Image {
  164. // x: 0
  165. // y: 0
  166. // width: 75
  167. // height: 75
  168. // visible: true
  169. // source: "qrc:/png/takeback.png"
  170. // fillMode: Image.PreserveAspectFit
  171. // }
  172. Text {
  173. id: facialrecognition_text_result
  174. x: 80
  175. y: 0
  176. width: 389
  177. height: 75
  178. visible: true
  179. text: ""
  180. font.pixelSize: 30
  181. horizontalAlignment: Text.AlignLeft
  182. verticalAlignment: Text.AlignVCenter
  183. color: "#ffffff"
  184. }
  185. }
  186. function callback_cameraImageGather(url)
  187. {
  188. facialrecognition_image_facial.source = url;
  189. }
  190. function callback_cameraImageRemain(url)
  191. {
  192. facialrecognition_btn_affirm.visible = true;
  193. facialrecognition_btn_retake.visible = true;
  194. interactiveFace.cameraImageStop();
  195. facialrecognition_image_facial.source = url;
  196. }
  197. // 插入人脸数据回复
  198. function call_insertUserFace_reply(json)
  199. {
  200. console.log("完成人脸提交");
  201. var jsonObjRoot = JSON.parse(json);
  202. var text = jsonObjRoot["text"];
  203. facialrecognition_text_result.text = text;
  204. }
  205. }