diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1fd5f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +/image/*.jpg +/app/__pycache__/*.pyc +test.jpg +test.json +app/test.json +/output/*.jpg +/app/testsql.py +/app/testPost.py +/app/.qiniu_pythonsdk_hostscache.json +*.idea/ +*.pyc +__pycache__/ + diff --git a/.idea/artifacts/wisdom_manager_service_war.xml b/.idea/artifacts/wisdom_manager_service_war.xml deleted file mode 100644 index 5fb6491..0000000 --- a/.idea/artifacts/wisdom_manager_service_war.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - $PROJECT_DIR$/wisdom_manager/wisdom_manager_service/target - - - wisdom_manager_service - war - - - - - - - \ No newline at end of file diff --git a/.idea/artifacts/wisdom_manager_service_war_exploded.xml b/.idea/artifacts/wisdom_manager_service_war_exploded.xml deleted file mode 100644 index a785e9e..0000000 --- a/.idea/artifacts/wisdom_manager_service_war_exploded.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - $PROJECT_DIR$/wisdom_manager/wisdom_manager_service/target/wisdom_manager_service - - - true - wisdom_manager_service - war - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/artifacts/wisdom_web_war.xml b/.idea/artifacts/wisdom_web_war.xml deleted file mode 100644 index 72f600b..0000000 --- a/.idea/artifacts/wisdom_web_war.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - $PROJECT_DIR$/wisdom_web/target - - - wisdom_web - war - - - - - - - \ No newline at end of file diff --git a/.idea/artifacts/wisdom_web_war_exploded.xml b/.idea/artifacts/wisdom_web_war_exploded.xml deleted file mode 100644 index e1dfaaf..0000000 --- a/.idea/artifacts/wisdom_web_war_exploded.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - $PROJECT_DIR$/wisdom_web/target/wisdom_web - - - true - wisdom_web - war - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index e1ca304..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 482dc1d..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/git_wisdom.iml b/.idea/git_wisdom.iml deleted file mode 100644 index c035f0b..0000000 --- a/.idea/git_wisdom.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__c3p0_c3p0_0_9_1_1.xml b/.idea/libraries/Maven__c3p0_c3p0_0_9_1_1.xml deleted file mode 100644 index dde215b..0000000 --- a/.idea/libraries/Maven__c3p0_c3p0_0_9_1_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_alibaba_druid_1_0_9.xml b/.idea/libraries/Maven__com_alibaba_druid_1_0_9.xml deleted file mode 100644 index a533418..0000000 --- a/.idea/libraries/Maven__com_alibaba_druid_1_0_9.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_alibaba_dubbo_2_5_3.xml b/.idea/libraries/Maven__com_alibaba_dubbo_2_5_3.xml deleted file mode 100644 index 963da73..0000000 --- a/.idea/libraries/Maven__com_alibaba_dubbo_2_5_3.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_alibaba_fastjson_1_2_57.xml b/.idea/libraries/Maven__com_alibaba_fastjson_1_2_57.xml deleted file mode 100644 index 260673c..0000000 --- a/.idea/libraries/Maven__com_alibaba_fastjson_1_2_57.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_github_jsqlparser_jsqlparser_0_9.xml b/.idea/libraries/Maven__com_github_jsqlparser_jsqlparser_0_9.xml deleted file mode 100644 index 16df4da..0000000 --- a/.idea/libraries/Maven__com_github_jsqlparser_jsqlparser_0_9.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_github_miemiedev_mybatis_paginator_1_2_15.xml b/.idea/libraries/Maven__com_github_miemiedev_mybatis_paginator_1_2_15.xml deleted file mode 100644 index 2062a96..0000000 --- a/.idea/libraries/Maven__com_github_miemiedev_mybatis_paginator_1_2_15.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_github_pagehelper_pagehelper_3_4_2_fix.xml b/.idea/libraries/Maven__com_github_pagehelper_pagehelper_3_4_2_fix.xml deleted file mode 100644 index 9e36af2..0000000 --- a/.idea/libraries/Maven__com_github_pagehelper_pagehelper_3_4_2_fix.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_github_sgroschupf_zkclient_0_1.xml b/.idea/libraries/Maven__com_github_sgroschupf_zkclient_0_1.xml deleted file mode 100644 index d8a0d28..0000000 --- a/.idea/libraries/Maven__com_github_sgroschupf_zkclient_0_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_codec_commons_codec_1_6.xml b/.idea/libraries/Maven__commons_codec_commons_codec_1_6.xml deleted file mode 100644 index e8a6a9f..0000000 --- a/.idea/libraries/Maven__commons_codec_commons_codec_1_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_1.xml b/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_1.xml deleted file mode 100644 index 18d3b23..0000000 --- a/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml b/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml deleted file mode 100644 index 7b5b3b7..0000000 --- a/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_io_commons_io_2_2.xml b/.idea/libraries/Maven__commons_io_commons_io_2_2.xml deleted file mode 100644 index f8084ec..0000000 --- a/.idea/libraries/Maven__commons_io_commons_io_2_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_logging_commons_logging_1_1_3.xml b/.idea/libraries/Maven__commons_logging_commons_logging_1_1_3.xml deleted file mode 100644 index 01c7b8e..0000000 --- a/.idea/libraries/Maven__commons_logging_commons_logging_1_1_3.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_net_commons_net_3_3.xml b/.idea/libraries/Maven__commons_net_commons_net_3_3.xml deleted file mode 100644 index 6844bee..0000000 --- a/.idea/libraries/Maven__commons_net_commons_net_3_3.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__io_netty_netty_3_7_0_Final.xml b/.idea/libraries/Maven__io_netty_netty_3_7_0_Final.xml deleted file mode 100644 index a80deb5..0000000 --- a/.idea/libraries/Maven__io_netty_netty_3_7_0_Final.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_servlet_jsp_api_2_0.xml b/.idea/libraries/Maven__javax_servlet_jsp_api_2_0.xml deleted file mode 100644 index b9bb9b6..0000000 --- a/.idea/libraries/Maven__javax_servlet_jsp_api_2_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_servlet_servlet_api_2_5.xml b/.idea/libraries/Maven__javax_servlet_servlet_api_2_5.xml deleted file mode 100644 index 679e09a..0000000 --- a/.idea/libraries/Maven__javax_servlet_servlet_api_2_5.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__jline_jline_0_9_94.xml b/.idea/libraries/Maven__jline_jline_0_9_94.xml deleted file mode 100644 index 903c339..0000000 --- a/.idea/libraries/Maven__jline_jline_0_9_94.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__joda_time_joda_time_2_5.xml b/.idea/libraries/Maven__joda_time_joda_time_2_5.xml deleted file mode 100644 index 7eb240e..0000000 --- a/.idea/libraries/Maven__joda_time_joda_time_2_5.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__jstl_jstl_1_2.xml b/.idea/libraries/Maven__jstl_jstl_1_2.xml deleted file mode 100644 index 40b1672..0000000 --- a/.idea/libraries/Maven__jstl_jstl_1_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml deleted file mode 100644 index d411041..0000000 --- a/.idea/libraries/Maven__junit_junit_4_12.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__log4j_log4j_1_2_16.xml b/.idea/libraries/Maven__log4j_log4j_1_2_16.xml deleted file mode 100644 index 11837b5..0000000 --- a/.idea/libraries/Maven__log4j_log4j_1_2_16.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_32.xml b/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_32.xml deleted file mode 100644 index 004138c..0000000 --- a/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_32.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__net_sf_trove4j_core_3_1_0.xml b/.idea/libraries/Maven__net_sf_trove4j_core_3_1_0.xml deleted file mode 100644 index 9460109..0000000 --- a/.idea/libraries/Maven__net_sf_trove4j_core_3_1_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_3_2.xml b/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_3_2.xml deleted file mode 100644 index 83cba3e..0000000 --- a/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_3_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_3_5.xml b/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_3_5.xml deleted file mode 100644 index 5601459..0000000 --- a/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_3_5.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_3_2.xml b/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_3_2.xml deleted file mode 100644 index 1c14963..0000000 --- a/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_3_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_zookeeper_zookeeper_3_4_7.xml b/.idea/libraries/Maven__org_apache_zookeeper_zookeeper_3_4_7.xml deleted file mode 100644 index 93026aa..0000000 --- a/.idea/libraries/Maven__org_apache_zookeeper_zookeeper_3_4_7.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_2.xml b/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_2.xml deleted file mode 100644 index a1f3d90..0000000 --- a/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml deleted file mode 100644 index f58bbc1..0000000 --- a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_javassist_javassist_3_15_0_GA.xml b/.idea/libraries/Maven__org_javassist_javassist_3_15_0_GA.xml deleted file mode 100644 index e27b8ed..0000000 --- a/.idea/libraries/Maven__org_javassist_javassist_3_15_0_GA.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_mybatis_mybatis_3_4_6.xml b/.idea/libraries/Maven__org_mybatis_mybatis_3_4_6.xml deleted file mode 100644 index 377b7a7..0000000 --- a/.idea/libraries/Maven__org_mybatis_mybatis_3_4_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_mybatis_mybatis_spring_2_0_1.xml b/.idea/libraries/Maven__org_mybatis_mybatis_spring_2_0_1.xml deleted file mode 100644 index f49fd3a..0000000 --- a/.idea/libraries/Maven__org_mybatis_mybatis_spring_2_0_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_quartz_scheduler_quartz_2_2_2.xml b/.idea/libraries/Maven__org_quartz_scheduler_quartz_2_2_2.xml deleted file mode 100644 index ebb1472..0000000 --- a/.idea/libraries/Maven__org_quartz_scheduler_quartz_2_2_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_6_1.xml b/.idea/libraries/Maven__org_slf4j_slf4j_api_1_6_1.xml deleted file mode 100644 index 38036e9..0000000 --- a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_6_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_2.xml b/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_2.xml deleted file mode 100644 index 7d29533..0000000 --- a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_7.xml b/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_7.xml deleted file mode 100644 index 1e67260..0000000 --- a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_7.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_6_4.xml b/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_6_4.xml deleted file mode 100644 index e183f55..0000000 --- a/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_6_4.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_aop_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_aop_5_1_5_RELEASE.xml deleted file mode 100644 index 7690fda..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_aop_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_aspects_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_aspects_5_1_5_RELEASE.xml deleted file mode 100644 index c8d5e07..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_aspects_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_beans_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_beans_5_1_5_RELEASE.xml deleted file mode 100644 index 4e3bb14..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_beans_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_context_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_context_5_1_5_RELEASE.xml deleted file mode 100644 index e32f9b7..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_context_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_context_support_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_context_support_5_1_5_RELEASE.xml deleted file mode 100644 index 97d1325..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_context_support_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_core_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_core_5_1_5_RELEASE.xml deleted file mode 100644 index ad54c38..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_core_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_expression_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_expression_5_1_5_RELEASE.xml deleted file mode 100644 index 456f68e..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_expression_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_jcl_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_jcl_5_1_5_RELEASE.xml deleted file mode 100644 index 28bc49a..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_jcl_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_jdbc_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_jdbc_5_1_5_RELEASE.xml deleted file mode 100644 index f416e50..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_jdbc_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_jms_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_jms_5_1_5_RELEASE.xml deleted file mode 100644 index f086fd6..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_jms_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_messaging_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_messaging_5_1_5_RELEASE.xml deleted file mode 100644 index 58085c7..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_messaging_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_tx_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_tx_5_1_5_RELEASE.xml deleted file mode 100644 index 784b25f..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_tx_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_web_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_web_5_1_5_RELEASE.xml deleted file mode 100644 index b8a2414..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_web_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_webmvc_5_1_5_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_webmvc_5_1_5_RELEASE.xml deleted file mode 100644 index b712d4f..0000000 --- a/.idea/libraries/Maven__org_springframework_spring_webmvc_5_1_5_RELEASE.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 1eb0969..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 04b8d02..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 75e2351..dd4cea1 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,259 @@ -# 智慧教室学生状态检测系统 -![avatar](http://62.234.50.12/NewBlog/tiaokan.jpg) +# 智慧教室树莓派端开发文档 -# 组员介绍 +# 一、开发环境 -CrankyPants123: https://github.com/CrankyPants123 +## 1.硬件平台 -zouchanglin: https://github.com/zouchanglin +- Linux系统 +- 树莓派3B+ +- 海康威视萤石C6T摄像头 -RoWe98: https://github.com/RoWe98 -ahojcn: https://github.com/ahojcn -MrDalili: https://github.com/MrDalili +## 2.开发语言和开发平台 + +- Python3 +- JetBrains PyCharm +- Linux系统(Debian) +- Unix内核系统(Mac OS X 10.14.3) + + + +## 3.开发依赖的开源库 + +- OpenCV开源视觉库 +- 多媒体处理工具ffmpeg +- MySQL 5.7数据库 +- 百度AI开放平台 +- Face++ 开放平台 + + + +## 4.版本控制工具 + +- 使用Git作为版本控制工具 +- 使用第三方git版本控制服务商github + + + +# 二、系统流程与软件架构设计 + +## 1.系统流程 + + + +![软件流程图](https://s2.ax1x.com/2019/05/21/Ez2xnx.md.png) + +系统具体流程如图所示 + +- 球机监控 +- 树莓派获取输入的RTSP视频流 +- ffmpeg处理截取关键帧 +- OpenCV分割人脸 +- 人脸库判断 +- 百度AI签到 +- 将出勤和学生状态发送给服务器 +- 计算学生抬头率 +- 将所有的结果写入数据库 + + + +## 2.模块设计 + +- FaceDetect 图像识别模块 +- FaceSearch 人脸搜索与判断模块 +- FaceDataBase 数据库读取与数据库操作实现模块 +- LoadVideo RTSP流处理模块 +- Upload 数据结果上传模块 +- GetJudge 逻辑关系处理模块 +- Wisdom 功能整合模块 + + + +# 三、功能实现 + +## 1.输入输出信息 + +1.1 输入信息 + +- 监控学生上课的动态视频 +- 监控视频的关键帧 +- 树莓派调用监控识别到的学生人脸信息 +- 学生的个人信息 + +1.2 输出信息 + +- 学生上课的状态 +- 抬头率 +- 课堂考勤分数 +- 考勤统计 +- 人像签到 +- 将信息插入数据库 + + + +## 2.分析过程实现 + +- 部分程序输出示例: + + 此输出实例为最后一次识别 这时系统已经记录了两次学生的睡觉信息 + +```2sleep1.jpg +4normal2.jpg +当前识别到人脸数为:4 +saving..... +saving..... +saving..... +saving..... +当前识别到的人体数为: 4 +调用服务器数据库 +当前出勤学生为:41609050201 +识别成功,已存储 +['41609050201'] +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +调用服务器数据库 +当前出勤学生为:41609050203 +识别成功,已存储 +['41609050201', '41609050203'] +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +调用服务器数据库 +当前出勤学生为:41609030216 +识别成功,已存储 +['41609050201', '41609050203', '41609030216'] +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +调用服务器数据库 +当前出勤学生为:41604090109 +识别成功,已存储 +['41609050201', '41609050203', '41609030216', '41604090109'] +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +{"status":1,"msg":"true","data":null} +已经把出勤信息发送给服务器 +200 +调用服务器数据库 +调用本地debug数据库 +当前识别到的学生为:['刘棋军', '刘梦', '史晓烁', '邹长林'] +当前学生出勤情况为: {'刘梦': 4, '史晓烁': 4, '刘棋军': 2, '邹长林': 2} +低头的学生为: [] +当前低头或睡觉学生情况为: {'刘棋军': 2, '邹长林': 2} +班级当前抬头率为:1.0 +出勤率为: 1.0 +清除临时文件完毕 +人名已经清除 + + +识别结束当前每个学生的出勤情况为: +{'刘梦': 4, '史晓烁': 4, '刘棋军': 2, '邹长林': 2} +本次识别中低头的学生情况为: +{'刘棋军': 2, '邹长林': 2} +学号信息为: +['41609050201', '41609050203', '41609030216', '41604090109'] +调用服务器数据库 +每个学生的抬头得分情况为: +{'刘梦': 40.0, '史晓烁': 40.0, '刘棋军': 20.0, '邹长林': 20.0} +{'41609050203': 1.0, '41609030216': 1.0, '41609050201': 0.5, '41604090109': 0.5} +{'41609050203': 40.0, '41609030216': 40.0, '41609050201': 20.0, '41604090109': 20.0}``` +``` + + + +## 3.调用API说明 + +- 使用了旷视科技的Face++开放平台的人脸识别模块facedetect +- 使用了百度AI开放平台的人脸识别API AipDetect +- 使用了百度AI开放平台的人脸搜索API AipFace +- 使用了百度AI开放平台的人体分析模块API AipBodyAnalysis + + + +# 五、构建方法 + +## 1.依赖库安装 + +- OpenCV安装 + + ```pip3 install python-opencv``` + +- 百度AI开放平台安装 + + ```pip3 install baidu-aip``` + +- ffmpeg安装 + + - 进入ffmpeg官方网站 http://ffmpeg.org/ 下载最新的版本 + + - 解压安装 + + ``` + tar -xjvf ffmpeg-3.3.1.tar.bz2 + cd ffmpeg-3.3.1/ + ./configure + make + make install + ``` + +- 安装git版本控制工具 + + ```yum install git``` + + + +## 2.软件下载运行 + +- 软件下载 + + 在terminal下输入以下命令 + + ```git clone git@github.com:RoWe98/WisdomClassRaspberry.git``` + +- 软件运行 + + ```bash + cd /WisdomClassRaspberry/app/ + python3 run.py + ``` + + + +# 六、项目开源地址 + +## 1.Github开源地址 + +```bash +https://github.com/xpuintelligence/Intelligence_classroom/tree/raspberryCode +``` + +## 2.开源协议 + +```bash +apache开源协议 +``` + +# 注意 部分机器测试bug解决方法 + + - bug是由于百度云ai开放平台的人脸识别库中的部分bugs + + - [解决方法](http://120.79.148.86/2019/05/10/Fix-Bug-Baidu-Aip/) diff --git a/RaspberryCode/README.md b/RaspberryCode/README.md deleted file mode 100644 index 8eae311..0000000 --- a/RaspberryCode/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# WisdomClassRaspberry -智慧教室树莓派端 - -/app 核心代码文件夹 - - LoadVideo.py rstp视频流读取模块 (有bug,暂时无法使用) - - FaceReco.py 图像识别处理模块 (bug,暂时无法使用) - - LoadDataBase.py 数据库读取模块 (bug,暂时无法使用) - - FaceSearch.py 人脸搜索模块 - - FaceDetect 人脸识别模块 - -/faces 裁剪人脸文件夹 - -/image 测试图片文件夹 diff --git a/RaspberryCode/app/FaceDetect.py b/RaspberryCode/app/FaceDetect.py deleted file mode 100644 index bfe38da..0000000 --- a/RaspberryCode/app/FaceDetect.py +++ /dev/null @@ -1,83 +0,0 @@ - -from aip import AipFace -import base64 -import os -import cv2 -import requests -from json import JSONDecoder - -class FaceDetect: - - def __init__(self, face_http_url, face_key, face_secret, file_path): - - self.url = face_http_url - self.key = face_key - self.secret = face_secret - self.file_path = file_path - - def getface(self): # 获取人脸识别信息 - - try: - - data = {"api_key": self.key, "api_secret": self.secret, "return_attributes": "gender,age,smiling,beauty"} - - files = {"image_file": open(file_path, "rb")} - - response = requests.post(self.url, data=data, files=files) - - req_con = response.content.decode('utf-8') - - req_dict = JSONDecoder().decode(req_con) - - faces = req_dict['faces'] - - # face_num = len(faces) - return faces - - except Exception: - pass - - def detect(self,faces): # 识别 - - face_num = len(faces) - print(face_num) - img = cv2.imread(self.file_path, cv2.IMREAD_COLOR) - for i in range(0,face_num): - face_rectangle = faces[i]['face_rectangle'] - # print(face_rectangle) - - left = face_rectangle['left'] - - top = face_rectangle['top'] - - width = face_rectangle['width'] - - height = face_rectangle['height'] - - cropImg = img[top - 20:top + height + 20, left - 20:left + width + 20] - - # 图片路径 - facebase = "../faces/" + str(i) + ".jpg" - print("saving.....") - cv2.imwrite(facebase, cropImg) - #cv2.rectangle(img, (left, top), (left + width, top + height), (0, 255, 0), 2) - - #img2 = cv2.resize(img, (1280,720), interpolation=cv2.INTER_CUBIC); - #cv2.imshow("detial",img2) - #cv2.waitKey(0) - - - - - -if __name__ == "__main__": - # face++的api地址密码 用于人脸识别 - face_http_url = "https://api-cn.faceplusplus.com/facepp/v3/detect" - face_key = "TISYNrP-YDndZwEYzO1rhlYbJuDZ7SxQ" - face_secret = "Ts5ELvCMeBLJkuxhcew7W7ouEX91uxWr" - - file_path = "../image/test.jpg" - - faceDetect = FaceDetect(face_http_url, face_key, face_secret, file_path) - faces = faceDetect.getface() - faceDetect.detect(faces) \ No newline at end of file diff --git a/RaspberryCode/app/FaceReco.py b/RaspberryCode/app/FaceReco.py deleted file mode 100755 index 549a645..0000000 --- a/RaspberryCode/app/FaceReco.py +++ /dev/null @@ -1,220 +0,0 @@ - -import cv2 -import requests -from json import JSONDecoder - - -import os -from aip import AipBodyAnalysis -from aip import AipFace -import base64 - - -import LoadDataBase - -studentRecoName = [] - - -class FaceReco: - - def __init__(self, http_url, key, secret): - - self.http_url = http_url - self.key = key - self.secret = secret - - # 连接face++ api - def ConnectAPI(self, filepath): - - try: - - data = {"api_key": self.key, "api_secret": self.secret, "return_attributes": "gender,age,smiling,beauty"} - - files = {"image_file": open(filepath, "rb")} - - response = requests.post(self.http_url, data=data, files=files) - - req_con = response.content.decode('utf-8') - - req_dict = JSONDecoder().decode(req_con) - - faces = req_dict['faces'] - - # print(faces) - - return faces - - - except Exception: - pass - - # 识别 - def faceReco(self, faces, filepath, client, LoadDataBase): - - face_num = len(faces) - - - - # 打开图片 - student_file = open(filepath, 'rb').read() - # 调用百度Ai识别人数 - student_num = client.bodyNum(student_file)['person_num'] - - print("一共有" + str(student_num) + "个学生") - - for i in range(0, face_num): - - face_rectangle = faces[i]['face_rectangle'] - - # face_info = str(face_rectangle['left']) + ' ' + str(face_rectangle['top']) + ' ' + str( - # face_rectangle['width']) + ' ' + str(face_rectangle['height']); - - left = face_rectangle['left'] - - top = face_rectangle['top'] - - width = face_rectangle['width'] - - height = face_rectangle['height'] - - cropImg = img[top - 20:top + height + 20, left - 20:left + width + 20] - - # 图片路径 - facebase = "C:/Users/Rex/Desktop/face++/FaceRecoV2.0/faces/" + str(i) + ".png" - - # 保存图片 - - cv2.imwrite(facebase, cropImg) - cv2.rectangle(img, (left, top), (left + width, top + height), (0, 255, 0), 2) - # print("图片保存") - - # 识别人脸 - for filename in os.listdir(r'C:/Users/Rex/Desktop/face++/FaceRecoV2.0/faceCompare'): - - facecompare = "C:/Users/Rex/Desktop/face++/FaceRecoV2.0/faceCompare/" + filename - - flag = self.FaceCompare(facebase, facecompare) - - if flag == 1: - facename = filename.replace('.jpg', '') - - print("对象为" + facename) - LoadDataBase.setStudentHeadupJudge(facename) - print("\n") - if facename not in studentRecoName: - studentRecoName.append(facename) - - print(studentRecoName) - - return student_num - - # 获得全班抬头率 - - def getHeadupRate(self, filepath, bodyClient): - - student_file = open(filepath, 'rb').read() - - headup_student_count = 0 - studentbody = bodyClient.bodyAnalysis(student_file) - student_num = studentbody['person_num'] - for i in range(0, student_num): - - student_nose_x = studentbody['person_info'][i]['body_parts']['nose']['x'] - student_nose_y = studentbody['person_info'][i]['body_parts']['nose']['y'] - if (student_nose_x != 0.0 and student_nose_y != 0.0): - headup_student_count = headup_student_count + 1 - - return headup_student_count - - # 人脸对比 - def FaceCompare(self, face1, face2, faceClient): - - try: - result = faceClient.match([ - { - 'image': base64.b64encode(open(face1, 'rb').read()), - 'image_type': 'BASE64', - }, - { - 'image': base64.b64encode(open(face2, 'rb').read()), - 'image_type': 'BASE64', - } - ]) - - compare_result = result['result']['score'] - if compare_result > 70: - return 1 - except Exception: - pass - - -if __name__ == "__main__": - - # face++的api地址密码 用于人脸识别 - face_http_url = "https://api-cn.faceplusplus.com/facepp/v3/detect" - face_key = "TISYNrP-YDndZwEYzO1rhlYbJuDZ7SxQ" - face_secret = "Ts5ELvCMeBLJkuxhcew7W7ouEX91uxWr" - - # 百度AI的api地址和密码 用于人数识别 - APP_ID = '15764227' - API_KEY = 'ciU5i0A0Rd77WIZMkBlgutGt' - SECRET_KEY = '8N3GpZKlOSLzyFknCsiH6ncoufCSMLaC' - - bodyClient = AipBodyAnalysis(APP_ID, API_KEY, SECRET_KEY) - faceClient = AipFace(APP_ID, API_KEY, SECRET_KEY) - - face = FaceReco(face_http_url, face_key, face_secret) - - # 统计学生人数 - - student_num_total = [] - - AllheadupRate = 0.0 - - # time_start=time.time() - - # 初始化数据库存储服务 - - host = "119.29.254.47" - - user = "root" - - database = "wisdom_classroom" - - password = "ndl.04551" - - LoadDataBase = LoadDataBase(host, user, database, password) - - # 将截图的所有图片进行分析 - for filename in os.listdir('C:/Users/Rex/Desktop/face++/FaceRecoV2.0/image/'): - if filename.endswith('.png'): - filepath = "C:/Users/Rex/Desktop/face++/FaceRecoV2.0/image/" + filename - - # 百度AI的api地址和密码 用于人数识别 - - faces = face.ConnectAPI(filepath) - - student_num = face.faceReco(faces, filepath, bodyClient, LoadDataBase) - - student_num_total.append(student_num) - - headupRate = face.getHeadupRate(filepath, bodyClient) - - # print("全班人数为{},抬头人数为{},抬头率为{:.2f}".format(student_num,headupRate,(headupRate/student_num))) - - AllheadupRate = AllheadupRate + headupRate / student_num - - # 抬头率 - AllheadupRate = round(AllheadupRate / 5, 2) - # 教室应到人数 - course_number_people = 31 - # 教室目前人数 - actual_number = max(student_num_total) - print("\n") - print("教室目前人数为{},这节课的抬头率为{}".format(actual_number, AllheadupRate)) - - # 存储全班抬头率 - - LoadDataBase.insertHeadUPSql(course_number_people, actual_number, headupRate) - - os.system("del" + "C:\\Users\\Rex\\Desktop\\face++\\FaceRecoV2.0\\faces\\*.jpg") diff --git a/RaspberryCode/app/FaceSearch.py b/RaspberryCode/app/FaceSearch.py deleted file mode 100644 index 8f03ad8..0000000 --- a/RaspberryCode/app/FaceSearch.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*-coding:utf-8 -*- - -from aip import AipFace -import base64 -import os - -class FaceSearch: - - def __init__(self,facefolder,imageType,groupIdList,client): - - self.facefolder = facefolder # 获取图片的文件夹 - self.client = client - self.imageType = imageType - self.groupIdList = groupIdList - - - - def search(self): - - for filename in os.listdir(self.facefolder): # 遍历图片文件夹中所有的人像 - face_path = self.facefolder + filename; - image = base64.b64encode(open(face_path, 'rb').read()) - try: - result = client.search(image, self.imageType, self.groupIdList); #调用人脸搜索在人脸库中搜索人脸返回json值 - face_id = result['result']['user_list'][0]['user_id'] #对JSON进行分析获取图片ID(学号) - print(face_id) - except Exception: - pass - -if __name__ == "__main__": - - # 百度AI人脸库的api地址和密码 用于人脸库搜索识别 - APP_ID = '15764893' - API_KEY = 'rHGwsXanKC4yWj4pXeepDZcc' - SECRET_KEY = 'qMONYxM1xTwnQh2q0DsHB7YG5Ht9LOal' - - client = AipFace(APP_ID, API_KEY, SECRET_KEY) # 实例化脸部搜索对象 - - imageType = "BASE64" - - groupIdList = "wisdom_class,1" - - facefolder = "../faces/" - - faceSearch = FaceSearch(facefolder, imageType, groupIdList, client) - - faceSearch.search() - - \ No newline at end of file diff --git a/RaspberryCode/app/LoadDataBase.py b/RaspberryCode/app/LoadDataBase.py deleted file mode 100755 index ec2fe4e..0000000 --- a/RaspberryCode/app/LoadDataBase.py +++ /dev/null @@ -1,89 +0,0 @@ -import pymysql -import time - - -class LoadDataBase: - - def __init__(self, host, user, database, password): - - self.host = host - self.user = user - self.database = database - self.password = password - - - # 获取课程id - def getCourseID(self): - - conn = pymysql.connect(host=self.host, user=self.user, password=self.password, database=self.database, - port=3306, charset="utf8") - - current_time = time.strftime('%Y-%m-%d %H:%M:%s', time.localtime(time.time())) - current_time_Hour = time.strftime('%H', time.localtime(time.time())) - current_time_Date = time.strftime('%Y-%m-%d ', time.localtime(time.time())) - if current_time == '08' or current_time == '10': - class_time = current_time_Date + current_time_Hour + ":10:00" - - sql = "select course_id from schedule_class where course_time = '%s';" - - data = (class_time) - - cursor = conn.cursor() - - try: - couse_id = cursor.execute(sql % data) - conn.commit() - return couse_id - except Exception as e: - conn.rollback() - - finally: - conn.close() - - # 班级抬头率 - def insertHeadUPSql(self, course_number_people, actual_number, headupRate): - - conn = pymysql.connect(host=self.host, user=self.user, password=self.password, database=self.database, - port=3306, charset="utf8") - - sql = "UPDATE `wisdom_classroom`.`schedule_class` SET `course_number_people` = '%s',`actual_number` = '%s', `course_headup` = '%s' WHERE (`course_id` = '%s');" - - course_id = self.getCourseID(); - - data = (course_number_people, actual_number, headupRate, course_id) - - cursor = conn.cursor() - - try: - cursor.execute(sql % data) - conn.commit() - print("插入成功") - except Exception as e: - conn.rollback() - - finally: - conn.close() - - # 插入学生抬头率 - def setStudentHeadupJudge(self, student_id): - - conn = pymysql.connect(host=self.host, user=self.user, password=self.password, database=self.database, - port=3306, charset="utf8") - - sql = "UPDATE `wisdom_classroom`.`headup_info` SET `student_id` = '%s',`judge1` = '1' WHERE (`course_id` = '%s');" - - course_id = self.getCourseID(); - - data = (student_id, course_id) - - cursor = conn.cursor() - - try: - cursor.execute(sql % data) - conn.commit() - print("插入成功") - except Exception as e: - conn.rollback() - - finally: - conn.close() diff --git a/RaspberryCode/app/LoadVideo.py b/RaspberryCode/app/LoadVideo.py deleted file mode 100644 index b6e2a4a..0000000 --- a/RaspberryCode/app/LoadVideo.py +++ /dev/null @@ -1,43 +0,0 @@ -import cv2 - - -class LoadVideo: - - def __init__(self, username, password, ip): - - self.username = username - self.password = password - self.ip = ip - - def load(self): - - video_path = "rstp://" + self.username + ":" + self.password + "@" + self.ip + "/" - - - cap = cv2.VideoCapture(video_path) - ret, frame = cap.read() - i = 1 - j = 0 - timeF = 1800 # 截图间隔为10分钟 - while ret: - ret, frame = cap.read() - cv2.imshow("frame", frame) - if (i % timeF == 1): - cv2.imwrite('/home/pi/Desktop/images/' + str(i) + '.jpg', frame) - j = j + 1 - if cv2.waitKey(1) & 0xFF == ord('q'): - break - i = i + 1 - if j == 10: # 一节课截图10次 - cv2.destroyAllWindows() - cap.release() - - -if __name__ == "__main__": - username = eval(print("请输入串流摄像头的用户名:")) - password = eval(print("请输入串流摄像头的密码:")) - ip = eval(print("请输入串流摄像头的ip地址:")) - - loadVideo = LoadVideo(username, password, ip) - - loadVideo.load() diff --git a/RaspberryCode/faces/0.jpg b/RaspberryCode/faces/0.jpg deleted file mode 100644 index 0cc4d30..0000000 Binary files a/RaspberryCode/faces/0.jpg and /dev/null differ diff --git a/RaspberryCode/faces/1.jpg b/RaspberryCode/faces/1.jpg deleted file mode 100644 index 6579426..0000000 Binary files a/RaspberryCode/faces/1.jpg and /dev/null differ diff --git a/RaspberryCode/faces/2.jpg b/RaspberryCode/faces/2.jpg deleted file mode 100644 index 79793f1..0000000 Binary files a/RaspberryCode/faces/2.jpg and /dev/null differ diff --git a/RaspberryCode/faces/3.jpg b/RaspberryCode/faces/3.jpg deleted file mode 100644 index 394b405..0000000 Binary files a/RaspberryCode/faces/3.jpg and /dev/null differ diff --git a/RaspberryCode/faces/4.jpg b/RaspberryCode/faces/4.jpg deleted file mode 100644 index 2f9f677..0000000 Binary files a/RaspberryCode/faces/4.jpg and /dev/null differ diff --git a/RaspberryCode/image/test.jpg b/RaspberryCode/image/test.jpg deleted file mode 100644 index a25bf7a..0000000 Binary files a/RaspberryCode/image/test.jpg and /dev/null differ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..7bfcd7a --- /dev/null +++ b/app/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc \ No newline at end of file diff --git a/app/.qiniu_pythonsdk_hostscache.json b/app/.qiniu_pythonsdk_hostscache.json new file mode 100644 index 0000000..ca3b7ea --- /dev/null +++ b/app/.qiniu_pythonsdk_hostscache.json @@ -0,0 +1 @@ +{"http:-oNo1ZYr8u46jWJhmjXE927uHg2v0iPdmVAdhga-:wisdom_class_image": {"upHosts": ["http://up.qiniu.com", "http://upload.qiniu.com", "-H up.qiniu.com http://183.131.7.3"], "ioHosts": ["http://iovip.qbox.me"], "deadline": 1557551292}, "http:-oNo1ZYr8u46jWJhmjXE927uHg2v0iPdmVAdhga-:datastroge": {"upHosts": ["http://up.qiniu.com", "http://upload.qiniu.com", "-H up.qiniu.com http://183.131.7.3"], "ioHosts": ["http://iovip.qbox.me"], "deadline": 1557845805}} \ No newline at end of file diff --git a/app/FaceDataBase.py b/app/FaceDataBase.py new file mode 100644 index 0000000..0105386 --- /dev/null +++ b/app/FaceDataBase.py @@ -0,0 +1,174 @@ +import pymysql +import time + +class FaceDataBase: + + def __init__(self, host, user, database, password): + + self.host = host + self.user = user + self.database = database + self.password = password + + + # 获取人名 + def get_student_name(self, student_id): + conn = pymysql.connect(host=self.host,user=self.user,password=self.password,database=self.database,port=3306,charset="utf8") + sql = "select name from tb_student where id = '%s'" + data = (student_id) + cursor = conn.cursor() + try: + cursor.execute(sql%data) + ret = cursor.fetchone() + student_name = ret[0] + return student_name + except Exception as e: + conn.rollback() + finally: + conn.close() + + # 获得当前班级所有学生的学号 + + def get_student_id_all(self): + student_id_class = [] + conn = pymysql.connect(host=self.host,user=self.user,password=self.password,database=self.database,port=3306,charset="utf8") + sql = "select id from tb_student;" + cursor = conn.cursor() + try: + cursor.execute(sql) + results = cursor.fetchall() + for student_id in results: + student_id_class.append(student_id[0]) + return student_id_class + except Exception as e: + conn.rollback() + finally: + conn.close() + + # 获得学生的id + def get_student_id(self,student_name): + conn = pymysql.connect(host=self.host,user=self.user,password=self.password,database=self.database,port=3306,charset="utf8") + sql = "select id from tb_student where name = '%s'"; + data = (student_name) + cursor = conn.cursor() + try: + cursor.execute(sql%data) + ret = cursor.fetchone() + student_id= ret[0] + return student_id + except Exception as e: + conn.rollback() + finally: + conn.close() + + + + # 获得当前班级所有学生的学号_debug 本地数据库 + def get_student_id_all_debug(self): + student_id_class = [] + conn = pymysql.connect(host=self.host,user=self.user,password=self.password,database=self.database,port=3306,charset="utf8") + sql = "select id from tb_student_debug4;" + cursor = conn.cursor() + try: + cursor.execute(sql) + results = cursor.fetchall() + for student_id in results: + student_id_class.append(student_id[0]) + return student_id_class + except Exception as e: + conn.rollback() + finally: + conn.close() + + + + # 获取课程id + def getCourseID(self): + conn = pymysql.connect(host=self.host,user=self.user,password=self.password,database=self.database,port=3306,charset="utf8") + sql = "select id from tb_courseitem where time = '%s';" + now_date = time.strftime('%Y-%m-%d 10:00:00') + print(now_date) + cursor = conn.cursor() + try: + cursor.execute(sql%now_date) + ret = cursor.fetchone() + courseitem_id= ret[0] + return courseitem_id + except Exception as e: + conn.rollback() + finally: + conn.close() + + + # 将不睡觉的学生插入数据库 + def attendance_insert_attend_nosleep(self,student_id_list,student_id_headuprate_dict,student_id_headuprate_score_dict): + conn = pymysql.connect(host=self.host,user=self.user,password=self.password,database=self.database,port=3306,charset="utf8") + sql = "INSERT INTO `team_model`.`tb_attendance` (`attendance_id`, `courseitem_id`, `student_id`, `create_date`, `status`, `head_up_rate`, `goal`, `sleep`, `headup_score`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" + courseitem_id = self.getCourseID() + #courseitem_id = "20190606140000" + create_date = time.strftime('%Y-%m-%d 10:00:00') + #create_date = "2019-06-14 10:00:00" + status = 'attend' + cursor = conn.cursor() + for student_id in student_id_list: + attendance_id = courseitem_id+'-'+student_id + head_up_rate = str(student_id_headuprate_dict[student_id]) + goal = '60' + sleep = '0' + headup_score = student_id_headuprate_score_dict[student_id] + data = (attendance_id,courseitem_id,student_id,create_date,status,head_up_rate,goal,sleep,headup_score) + try: + cursor.execute(sql%data) + conn.commit() + except Exception as e: + conn.rollback() + + conn.close() + + + # 将睡觉的学生插入数据库 + def attendance_insert_attend_sleep(self, sleep_student_dict,student_id_headuprate_dict,student_id_headuprate_score_dict): + + conn = pymysql.connect(host=self.host,user=self.user,password=self.password,database=self.database,port=3306,charset="utf8") + sql = "INSERT INTO `team_model`.`tb_attendance` (`attendance_id`, `courseitem_id`, `student_id`, `create_date`, `status`, `head_up_rate`, `goal`, `sleep`, `headup_score`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" + courseitem_id = self.getCourseID() + create_date = time.strftime('%Y-%m-%d 10:00:00') + status = 'attend' + cursor = conn.cursor() + for sleep_student_name in sleep_student_dict.keys(): + sleep_student_id = self.get_student_id(sleep_student_name) + attendance_id = courseitem_id + '-' + sleep_student_id + head_up_rate = str(student_id_headuprate_dict[sleep_student_id]) + goal = '60' + sleep = '1' + headup_score = student_id_headuprate_score_dict[sleep_student_id] + data = (attendance_id, courseitem_id, sleep_student_id, create_date, status, head_up_rate, goal, sleep, headup_score) + try: + cursor.execute(sql % data) + conn.commit() + except Exception as e: + conn.rollback() + + conn.close() + + + # 获取学生的手机号 + + def get_student_number(self, student_name): + + conn = pymysql.connect(host=self.host, user=self.user, password=self.password, database=self.database, + port=3306, charset="utf8") + sql = "select phone_code from tb_student where name = '%s'" + + data = (student_name) + cursor = conn.cursor() + try: + cursor.execute(sql % data) + ret = cursor.fetchone() + phone_code = ret[0] + return phone_code + except Exception as e: + conn.rollback() + finally: + conn.close() + diff --git a/app/FaceDetect.py b/app/FaceDetect.py new file mode 100644 index 0000000..eba4467 --- /dev/null +++ b/app/FaceDetect.py @@ -0,0 +1,125 @@ + +from aip import AipFace +from aip import AipBodyAnalysis +import base64 +import os +import cv2 +import requests +from json import JSONDecoder +from FaceSearch import FaceSearch + +face_pixel = [] + +class FaceDetect: + + def __init__(self, face_http_url, face_key, face_secret, file_path, client_baidu_body, client_baidu_face): + + self.url = face_http_url + self.key = face_key + self.secret = face_secret + self.file_path = file_path + self.client_baidu_body = client_baidu_body + self.client_baidu_face = client_baidu_face + self.face_num_class = 0 + self.student_num_class = 0 + self.headup_student = 0 + + def getface(self): # 获取人脸识别信息 + + try: + + data = {"api_key": self.key, "api_secret": self.secret, "return_attributes": "gender,age,smiling,beauty"} + + files = {"image_file": open(self.file_path, "rb")} + + response = requests.post(self.url, data=data, files=files) + + req_con = response.content.decode('utf-8') + + req_dict = JSONDecoder().decode(req_con) + + faces = req_dict['faces'] + return faces + + except Exception: + pass + + def detect(self, faces): # 识别 + + face_num = len(faces) # 获取api返回的人脸数 + self.face_num_class = face_num + print("当前识别到人脸数为:"+str(face_num)) + img = cv2.imread(self.file_path, cv2.IMREAD_COLOR) + for i in range(0,face_num): + # 获取人脸坐标 + face_rectangle = faces[i]['face_rectangle'] + left = face_rectangle['left'] + top = face_rectangle['top'] + width = face_rectangle['width'] + height = face_rectangle['height'] + face_pixel_info = str(left)+","+str(top)+","+str(width)+","+str(height) + # print(face_pixel_info) + face_pixel.append(face_pixel_info) + + # 准备截取人脸 获取需要截取的区域坐标 + cropImg = img[top - 20:top + height + 20, left - 20:left + width + 20] + + # 图片路径 + facebase = "../faces/" + str(i) + ".jpg" + print("saving.....") + cv2.imwrite(facebase, cropImg) + + return face_pixel + + # 判断人数 + def get_student_num(self): + + # 打开图片 + student_file = open(self.file_path, 'rb').read() + # 调用百度Ai识别人数 + try: + self.student_info_class = self.client_baidu_body.bodyAnalysis(student_file) + student_num = self.student_info_class['person_num'] + + self.student_num_class = student_num + return student_num + except Exception: + os.chdir("../faces") + os.system("rm -rf *.jpg") + pass + + # 判断抬头率 + def get_headup_rate(self): + + # 初始化抬头率 + for i in range(0, self.student_num_class): + student_nose_y = self.student_info_class['person_info'][0]['body_parts']['nose']['y'] + student_nose_x = self.student_info_class['person_info'][0]['body_parts']['nose']['x'] + if student_nose_x is not 0.0 and student_nose_y is not 0.0: + self.headup_student = self.headup_student + 1 + try: + # 修复了一个bug 抬头人数判断问题 + if self.headup_student > self.face_num_class: + self.headup_student = self.face_num_class + headup_rate = self.headup_student/self.student_num_class + return headup_rate + except Exception: + pass + + # 判断出勤率 + def attendence(self): + + # 获得出勤率 + try: + attendence = self.face_num_class/self.student_num_class + return attendence + except Exception: + pass + + + + + + + + diff --git a/app/FaceNotice.py b/app/FaceNotice.py new file mode 100644 index 0000000..d2c1eda --- /dev/null +++ b/app/FaceNotice.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +#coding=utf-8 + +from aliyunsdkcore.client import AcsClient +from aliyunsdkcore.request import CommonRequest + +class FaceNotice: + + def notice(phone_number,student_name): + client = AcsClient('******************', '******************', 'default') + + request = CommonRequest() + request.set_accept_format('json') + request.set_domain('dysmsapi.aliyuncs.com') + request.set_method('POST') + request.set_protocol_type('https') # https | http + request.set_version('2017-05-25') + request.set_action_name('SendSms') + + request.add_query_param('PhoneNumbers', str(phone_number)) + request.add_query_param('SignName', "瑞克斯的博客系统") + request.add_query_param('TemplateCode', "SMS_166095489") + format = "{\"name\":\""+str(student_name)+"\"}" + request.add_query_param('TemplateParam', format) + + response = client.do_action(request) + # python2: print(response) + print(str(response, encoding = 'utf-8')) diff --git a/app/FaceSearch.py b/app/FaceSearch.py new file mode 100644 index 0000000..f1fa27b --- /dev/null +++ b/app/FaceSearch.py @@ -0,0 +1,174 @@ +# -*-coding:utf-8 -*- +import base64 +import os +import time +from FaceDataBase import FaceDataBase +import requests + +# 测试用列表 是要更改的 目前希望是每个教室应该在的学生对应一个表 +# 教室目前所在的学生 +# student_actual_list = [] +# 这样可以获得这个教室里面所有学生的学号信息 +student_name_list = [] + + + +class FaceSearch: + + def __init__(self, facefolder, imageType, groupIdList, client_baidu_face): + + self.facefolder = facefolder # 获取图片的文件夹 + self.client_baidu_face = client_baidu_face + self.imageType = imageType + self.groupIdList = groupIdList + + # 人脸搜索 + + def search(self): + # 出勤学生信息防止重复 + student_id_list_actual = [] + # 出勤学生学号信息的列表 + student_id_list = [] + # 这样可以获得这个教室里面所有学生的学号信息 + student_name_list = [] + + for filename in os.listdir(self.facefolder): # 遍历图片文件夹中所有的人像 + if filename.endswith(".jpg"): + face_path = self.facefolder + filename; + image = base64.b64encode(open(face_path, 'rb').read()) + try: + # 调用人脸搜索在人脸库中搜索人脸返回json值 + result = self.client_baidu_face.search(image, self.imageType, self.groupIdList); + face_id = result['result']['user_list'][0]['user_id'] # 对JSON进行分析获取图片ID(学号) + time.sleep(0.3) # 同时调用次数太多导致api 故加300毫秒延迟 + + faceDataBase = self.initdatabase() + student_id = str(face_id) + student_id_list.append(student_id) + # 判断学生出勤情况 + # self.get_headup_rate_each_student(student_id, faceDataBase) + # print(str(student_id)+"的出勤情况已登记") + print('当前出勤学生为:' + str(student_id)) + + student_name = faceDataBase.get_student_name(student_id) # 返回学生姓名 + if student_name is not None: + student_name_list.append(student_name) + print("识别成功,已存储") + + # 防止重复 + for student_id in student_id_list: + if student_id not in student_id_list_actual: + student_id_list_actual.append(student_id) + print(student_id_list_actual) + #self.post_student_list_to_server(student_id_list_actual) + except Exception: + #os.chdir("../faces") + #os.system("rm -rf *.jpg") + pass + + student_headown_list = [] + if student_headown_list is not None: + student_headown_list = self.judge_id_In_Not(student_id_list) + else: + student_headown_list = [] + return student_name_list, student_headown_list, student_id_list_actual + + # 初始化数据库对象 服务器数据库 + def initdatabase(self): + # 数据库信息 + print("调用服务器数据库") + host = "101.132.78.78" + user = "root" + database = "team_model" + password = "nanshen166013" + + # 调用数据库 + faceDataBase = FaceDataBase(host, user, database, password) # 初始化数据 + return faceDataBase + + # 初始化数据库对象_Debug 本地数据库 + def initdatabase_debug(self): + print("调用本地debug数据库") + # 数据库信息 + host = "127.0.0.1" + user = "root" + database = "Wisdom_Class" + password = "123456" + + # 调用数据库 + faceDataBase_debug = FaceDataBase(host, user, database, password) # 初始化数据 + return faceDataBase_debug + + # 每个学生的抬头率 + def get_headup_rate_each_student(self, student_id, faceDataBase): + + # faceDataBase = self.initdatabase() + student_id_list = faceDataBase.get_student_id_all() + if student_id in student_id_list: + faceDataBase.attendence_insert(student_id) + + # 判断当前学号是否在该班级学号列表中 + def judge_id_In_Not(self, student_id_list): + # 低头学生学号信息的列表 + student_headown_list = [] + # 目前教室里真实存在的学生 + student_actual_list_now = [] + # 初始化数据库对象_服务器 + faceDataBase = self.initdatabase() + # 初始化数据库对象_debug + faceDataBase_debug = self.initdatabase_debug() + # 利用当前教室学生的学号和检测到的学生的学号求补集 + student_actual_list = faceDataBase_debug.get_student_id_all_debug() # 当前使用的是本地测试数据库 + # 输出当前教室应该有的学生 + print("输出当前教室应该有的学生"+str(student_actual_list)) + if student_actual_list is not None: + for actual_student in student_actual_list: + if actual_student is not None: + student_actual_list_now.append(actual_student) + # 输出当前教室实际存在的学生 + print("输出当前教室实际存在的学生"+str(student_actual_list_now)) + student_left = list(set(student_actual_list_now) - set(student_id_list)) + # 如果补集存在(没有抬头的学生存在) + try: + if len(student_left) or len(student_left) <= len(student_actual_list) / 2: + for student_left_name in student_left: + # 返回当前低头的学生的id + student_headown_name = faceDataBase.get_student_name(str(student_left_name)) + # 将低头学生的id保存到低头学生的列表中 + student_headown_list.append(student_headown_name) + + #student_headown_list=self.if_all_write(student_actual_list, student_headown_list) + # print("当前低头的学生为:"+str(student_headown_list)) + return student_headown_list + except Exception: + pass + + + # 判断是不是大家都在写作业做题 + def if_all_write(self, student_actual_list, student_headown_list): + # 当前教室人数 + judge_student_num = len(student_actual_list) + #判断当前低头人数是否多于全班人数的一半 + if len(student_headown_list) >= judge_student_num / 2: + student_headown_list = [] + return student_headown_list + else: + return student_headown_list + + + # 将点名的情况发到服务器 + def post_student_list_to_server(self,student_id_list_actual): + + # api地址 + url = "http://47.103.14.73:8080/wisdom_web/monitorStudent/setStudentStatus" + #for student_id in student_id_list_actual: + body = {"status": '2', "id": "1","msg":str(student_id_list_actual)} + response = requests.post(url, data=body) + now_respone_server = response.text + status = '"status":1' + print(response.text) + if status in now_respone_server: + print("已经把出勤信息发送给服务器") + print(response.status_code) + + diff --git a/app/GetJudge.py b/app/GetJudge.py new file mode 100644 index 0000000..4e77b20 --- /dev/null +++ b/app/GetJudge.py @@ -0,0 +1,137 @@ +# 用于判断当前学生的状态 +import requests + +from FaceDataBase import FaceDataBase + +class GetJudge: + + def __init__(self,sleepdict,student_attendancedict): + + # 初始化睡觉判断和出勤判断字典 + # self.sleepdict = dict() + # self.student_attendancedict = dict() + # 学生睡觉的字典 + self.sleepdict = sleepdict + # 学生识别情况的字典 + self.student_attendancedict = student_attendancedict + + # 判断学生是不是在睡觉或者不认真听讲 + def sleepJudge(self, student_headown_list): + if student_headown_list is not None: + if len(student_headown_list): + print(student_headown_list) + for student_name in student_headown_list: + if student_name in self.sleepdict.keys(): + self.sleepdict[student_name] = self.sleepdict[student_name]+1 + else: + self.sleepdict[student_name] = 1 + + #print(self.sleepdict) + + # 判断学生多次低头的情况是不是在睡觉 + + for student_name in self.sleepdict.keys(): + if(self.sleepdict[student_name]) >=2: + print("请提醒"+student_name+"同学,该同学可能正在睡觉") + faceDataBase = GetJudge.initdatabase() + student_id = faceDataBase.get_student_id(student_name) + # GetJudge.post_sleep_student(student_id) + + return self.sleepdict + + # 准备链接数据库 返回数据库对象 + + def initdatabase(): + # 数据库信息 + print("调用服务器数据库") + host = "101.132.78.78" + user = "root" + database = "team_model" + password = "nanshen166013" + faceDataBase = FaceDataBase(host, user, database, password) + return faceDataBase + + # 判断学生出勤情况的查询 + + def student_attendance_Judge(self, student_name_list): + + if len(student_name_list): + for student_name in student_name_list: + if student_name in self.student_attendancedict.keys(): + self.student_attendancedict[student_name] = self.student_attendancedict[student_name]+1 + else: + self.student_attendancedict[student_name] = 1 + + return self.student_attendancedict + + + + # 该学生本节课的抬头(认真听课)分数,该学生本节课的抬头率 + def each_student_headupRate(student_attendancedict_end,reco_time): + + # 调用数据库 + faceDataBase = GetJudge.initdatabase() + # 学生分数的字典 + student_score_dict = dict() + # 学生抬头率的字典 + student_headuprate_dict = dict() + # 学生id+抬头成绩的字典 + student_id_headuprate_score_dict = dict() + # 对每个学生的分数进行判断 + for student_name in student_attendancedict_end.keys(): + student_headuprate = student_attendancedict_end[student_name]/reco_time + student_score = (student_attendancedict_end[student_name]/reco_time)*40 + student_id = faceDataBase.get_student_id(student_name) + student_headuprate_dict[student_id] = student_headuprate + student_score_dict[student_name] = student_score + student_id_headuprate_score_dict[student_id] = student_score + + return student_score_dict,student_headuprate_dict,student_id_headuprate_score_dict + + + # 给服务器发送学生睡觉的post请求 + def post_sleep_student(student_id): + # api地址 + url = "http://47.103.14.73:8080/wisdom_web/monitorStudent/setStudentStatus" + # 1为睡觉 + student_id = str(student_id) + body = {"status":'1', "id":student_id} + + response = requests.post(url,data = body) + now_respone_server = response.text + status = '"status":1' + print(response.text) + if status in now_respone_server: + print("已经向服务器发送了睡觉信息") + print(response.status_code) + + + def post_absent_student(student_list): + + # api地址 + url = "http://47.103.14.73:8080/wisdom_web/monitorStudent/setStudentStatus" + + body = {"status": '3', "id": "1","msg":str(student_list)} + + response = requests.post(url, data=body) + now_respone_server = response.text + status = '"status":1' + print(response.text) + if status in now_respone_server: + print("已经向服务器发送了缺勤信息") + print(response.status_code) + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/LoadVideo.py b/app/LoadVideo.py new file mode 100644 index 0000000..82e3395 --- /dev/null +++ b/app/LoadVideo.py @@ -0,0 +1,15 @@ + +import cv2 +import time +import os + +class LoadVideo: + + # 截图 利用ffmpeg + def load(user, ip, password): + + print("开始捕获图片") + localtime = time.strftime("%H-%M-%S") + os.system("ffmpeg -i rtsp://"+user+":"+password+"@"+ip+":554/h264/ch1/main/av_stream -y -f mjpeg -t 0.001 -s 1280x720 "+"../image/"+localtime+".jpg") + print("已经截图成功,名字为: "+localtime+".jpg") + diff --git a/app/Upload.py b/app/Upload.py new file mode 100644 index 0000000..b8bc3c8 --- /dev/null +++ b/app/Upload.py @@ -0,0 +1,27 @@ +from qiniu import Auth, put_file, etag +import qiniu.config +import os + +class Upload: + + def __init__(self): + + # 七牛云的access_key 和 secret_key + self.access_key = "-oNo1ZYr8u46jWJhmjXE927uHg2v0iPdmVAdhga-" + self.secret_key = "Jh2afu387eAhQMaATFAHAEZJvhwGio-ohU17f2xH" + + def upload(self,filepath,filename): + #构建鉴权对象 + q = Auth(self.access_key, self.secret_key) + #要上传的空间 + bucket_name = 'wisdom_class_image' + #要上传文件的本地路径 + localfile = filepath + #上传后保存的文件名 + key = filename + #生成上传 Token,可以指定过期时间等 + token = q.upload_token(bucket_name, key, 3600) + ret, info = put_file(token, key, localfile) + print(info) + assert ret['key'] == key + assert ret['hash'] == etag(localfile) \ No newline at end of file diff --git a/app/Wisdom.py b/app/Wisdom.py new file mode 100644 index 0000000..0af4e1e --- /dev/null +++ b/app/Wisdom.py @@ -0,0 +1,153 @@ +# -*-coding:utf-8 -*- + +from aip import AipFace +from aip import AipBodyAnalysis +import os +import cv2 +import numpy as np +from FaceSearch import FaceSearch +from FaceDetect import FaceDetect +from PIL import Image, ImageDraw, ImageFont +from GetJudge import GetJudge +from Upload import Upload + + +class Wisdom: + + def drawInfo(img, student_name_list, headup_rate, attendence, student_num, image_height, image_width, filename): + + output_path = "../output/" + filename + # 利用pillow包输出中文 + pil_im = Image.fromarray(img) + draw = ImageDraw.Draw(pil_im) + font = ImageFont.truetype("STHeiti Light.ttc", 65, encoding="utf-8") + draw.text((int(image_width * (1 / 10)), int(image_height * (1 / 5))), "student: " + str(student_name_list), + (0, 255, 0), font=font) + img = cv2.cvtColor(np.array(pil_im), cv2.COLOR_RGB2BGR) + + img = cv2.putText(img, "headupRate: " + str(headup_rate), + (int(image_width * (1 / 10)), int(image_height * (1 / 5) + 100)), cv2.FONT_HERSHEY_SIMPLEX, 2, + (0, 255, 0), 3) + img = cv2.putText(img, "Attendence: " + str(attendence), + (int(image_width * (1 / 10)), int(image_height * (1 / 5) + 200)), cv2.FONT_HERSHEY_SIMPLEX, 2, + (0, 255, 0), 3) + img = cv2.putText(img, "student_num: " + str(student_num), + (int(image_width * (1 / 10)), int(image_height * (1 / 5) + 300)), cv2.FONT_HERSHEY_SIMPLEX, 2, + (0, 255, 0), 3) + + img2 = cv2.resize(img, (1280, 720), interpolation=cv2.INTER_CUBIC); + + # 保存处理之后的图片 + # cv2.imwrite(output_path,img2) + # 准备上传七牛云 + upload = Upload() + # upload.upload(output_path,filename) + + def run_wisdom(sleepdict, student_attendancedict): + + #global faceSearch + #global student_id_list_actual + # face++的api地址密码 用于人脸识别 + face_http_url = "https://api-cn.faceplusplus.com/facepp/v3/detect" + face_key = "TISYNrP-YDndZwEYzO1rhlYbJuDZ7SxQ" + face_secret = "Ts5ELvCMeBLJkuxhcew7W7ouEX91uxWr" + + # 百度AI人脸库的api地址和密码 用于人脸库搜索识别 + APP_ID_FACE = '15764893' + API_KEY_FACE = 'rHGwsXanKC4yWj4pXeepDZcc' + SECRET_KEY_FACE = 'qMONYxM1xTwnQh2q0DsHB7YG5Ht9LOal' + + # 百度AI人体的api信息 用于人体识别分析 + APP_ID_BODY = "15764227" + API_KEY_BODY = 'ciU5i0A0Rd77WIZMkBlgutGt' + SECRET_KEY_BODY = '8N3GpZKlOSLzyFknCsiH6ncoufCSMLaC' + # 实例化人脸分析搜索对象 + client_baidu_face = AipFace(APP_ID_FACE, API_KEY_FACE, SECRET_KEY_FACE) + # 实例化人体分析对象 + client_baidu_body = AipBodyAnalysis(APP_ID_BODY, API_KEY_BODY, SECRET_KEY_BODY) + + # 实例化判断类的对象 + getJudge = GetJudge(sleepdict, student_attendancedict) + + # 测试图片的文件位置 + for filename in os.listdir("../image/"): + if filename.endswith('.jpg'): + print(filename) + file_path = "../image/" + filename + # 实例化人脸检测对象 + faceDetect = FaceDetect(face_http_url, face_key, face_secret, file_path, client_baidu_body, + client_baidu_face) + faces = faceDetect.getface() # 获取人脸数 + # 分割人脸存储到指定文件夹 + face_pixel = faceDetect.detect(faces) + student_num = faceDetect.get_student_num() + # print(face_pixel) + print("当前识别到的人体数为: " + str(student_num)) + + # 测试图片格式为BASE64 + imageType = "BASE64" + groupIdList = "wisdom_class,1" # 人脸库的名字和id + facefolder = "../faces/" # 存储的位置 + faceSearch = FaceSearch(facefolder, imageType, groupIdList, client_baidu_face) # 实例化人脸搜索对象 + # student_name_list = [] # 初始化人名列表 + student_name_list, student_headown_list, student_id_list_actual = faceSearch.search() # 人脸库人脸搜素 + print("当前识别到的学生为:" + str(student_name_list)) + # 当前学生的单个考勤查询 + student_attendancedict = getJudge.student_attendance_Judge(student_name_list) + print("当前学生出勤情况为: " + str(student_attendancedict)) + # if len(student_headown_list): + if len(student_headown_list): + print("低头的学生为: " + str(student_headown_list)) + # 检测学生是不是睡觉或不认真听课 + sleepdict = getJudge.sleepJudge(student_headown_list) + + # 防止输出为空 + if sleepdict is not None: + sleepdict_actual = sleepdict + if len(sleepdict_actual): + print("当前低头或睡觉学生情况为: " + str(sleepdict_actual)) + else: + sleepdict_actual = {} + + headup_rate = faceDetect.get_headup_rate() + print("班级当前抬头率为:" + str(headup_rate)) + attendence = faceDetect.attendence() + print("出勤率为: " + str(attendence)) + + # 读取图片 + img = cv2.imread(file_path, cv2.IMREAD_COLOR) + # 获取图片的尺寸 + imgsize = img.shape + # 图片的高 + image_height = imgsize[0] + # 图片宽 + image_width = imgsize[1] + for i in range(0, len(face_pixel)): + face_rectangle = list(face_pixel[i].split(",")) + left = int(face_rectangle[0]) + top = int(face_rectangle[1]) + width = int(face_rectangle[2]) + height = int(face_rectangle[3]) + + # print(face_rectangle) + cv2.rectangle(img, (left, top), (left + width, top + height), (0, 255, 0), 2) + + # 利用pillow包输出中文 + + Wisdom.drawInfo(img, student_name_list, headup_rate, attendence, student_num, image_height, image_width, + filename) + + # 删除faces文件夹的待识别面部 + os.chdir("../faces") + os.system("rm -rf *.jpg") + print("清除临时文件完毕") + student_name_list.clear() + print("人名已经清除") + print() + faceSearch.post_student_list_to_server(student_attendancedict) + return sleepdict_actual, student_attendancedict, student_id_list_actual + # if sleepdict_actual is None: + # sleepdict_actual = {} + # return sleepdict_actual, student_attendancedict, student_id_list_actual + # else: + diff --git a/app/debugFunc.py b/app/debugFunc.py new file mode 100644 index 0000000..72610f0 --- /dev/null +++ b/app/debugFunc.py @@ -0,0 +1,88 @@ +# 这个程序用来测试新写的方法和功能 + +import os +from Wisdom import Wisdom +from GetJudge import GetJudge +from FaceDataBase import FaceDataBase +from FaceNotice import FaceNotice + +# 初始化数据库 +def initdatabase(): + # 数据库信息 + print("调用服务器数据库") + host = "101.132.78.78" + user = "root" + database = "team_model" + password = "nanshen166013" + faceDataBase = FaceDataBase(host, user, database, password) + return faceDataBase + + + +# 给睡觉学生发短信 +def send_message(sleepdict_end): + + faceDataBase = initdatabase() + + for student_name in sleepdict_end.keys(): + student_id = faceDataBase.get_student_id(student_name) + phone_code = faceDataBase.get_student_number(student_name) + + GetJudge.post_sleep_student(str(student_id)) + FaceNotice.notice(phone_code, student_name) + + + + +# 初始化睡觉判断和出勤判断字典 +sleepdict = dict() +student_attendancedict = dict() + +sleepdict_end, student_attendancedict_end, student_id_list_actual= Wisdom.run_wisdom(sleepdict,student_attendancedict) + +print() +print("识别结束当前每个学生的出勤情况为:") +print(str(student_attendancedict_end)) +print("本次识别中低头的学生情况为:") +print(str(sleepdict_end)) + +# 缺勤学生id列表 +sleepdict_absent_list = [] + +for student_id in sleepdict_end.keys(): + if sleepdict_end[student_id] > 3: + sleepdict_absent_list.append(student_id) + +print("缺勤学生为:"+str(sleepdict_absent_list)) +GetJudge.post_absent_student(sleepdict_absent_list) + + +print("学号信息为:") +print(student_id_list_actual) + + +#phone_number = "15291418231" +#student_name = "邹长林" + + +send_message(sleepdict_end) + +# 识别次数 目前设置为4次 + +reco_time = 4 +student_score_dict,student_headuprate_dict,student_id_headuprate_score_dict = GetJudge.each_student_headupRate(student_attendancedict_end,reco_time) + +print("每个学生的抬头得分情况为:") +print(str(student_score_dict)) +print(str(student_headuprate_dict)) +print(str(student_id_headuprate_score_dict)) + +# 初始化数据库对象 +# facedatabase = initdatabase() +# 将没有睡觉的学生的出勤情况插入数据库 +# facedatabase.attendance_insert_attend_nosleep(student_id_list_actual,student_headuprate_dict,student_id_headuprate_score_dict) + +# 将睡觉的学生的出勤情况插入数据库 +# facedatabase.attendance_insert_attend_sleep(sleepdict_end,student_headuprate_dict,student_id_headuprate_score_dict) +os.chdir("../faces") +os.system("rm -rf *.jpg") \ No newline at end of file diff --git a/app/deleteCache.py b/app/deleteCache.py new file mode 100644 index 0000000..923976b --- /dev/null +++ b/app/deleteCache.py @@ -0,0 +1,4 @@ +import os + +os.chdir("../faces") +os.system("rm -rf *.jpg") \ No newline at end of file diff --git a/app/run.py b/app/run.py new file mode 100644 index 0000000..5f6c031 --- /dev/null +++ b/app/run.py @@ -0,0 +1,113 @@ +# -*-coding:utf-8 -*- + +import os +import time +from LoadVideo import LoadVideo +from Wisdom import Wisdom +from GetJudge import GetJudge +import sys + +# 初始化睡觉判断和出勤判断字典 +sleepdict = dict() +student_attendancedict = dict() + +# 获取图片 +def get_image(user, ip, password): + LoadVideo.load(user, ip, password) + + +# 识别程序 +def run_program(sleepdict,student_attendancedict): + sleepdict_run = sleepdict + student_attendancedict_run = student_attendancedict + sleepdict_end, student_attendancedict_end, student_id_list_actual = Wisdom.run_wisdom(sleepdict_run,student_attendancedict_run) + clean() + return sleepdict_end, student_attendancedict_end, student_id_list_actual + + +# 清除缓存 +def clean(): + os.chdir("../image") + os.system("rm -rf *.jpg") + os.chdir("../output") + os.system("rm -rf *.jpg") + print("清除完毕") + + +def author(): + print() + print("欢迎使用智慧教室学生状态检测系统(树莓派端),按Ctrl+C退出程序") + print("项目地址:https://github.com/RoWe98/WisdomClassRaspberry") + print("在使用之前请先登陆管理员账号") + print() + print("账号: ", end="") + #account = input() + account = "admin" + print("密码: ", end="") + #password_login = getpass.getpass() + password_login = "123" + if account == "admin" and password_login == "123": + return 1 + else: + return 0 + + +if __name__ == "__main__": + + flag = author() + if flag == 1: + print("登陆成功") + print("是否继续?:(Y/N)",end = "") + #stillflag = input() + stillflag = 'y' + if stillflag == "Y" or stillflag == "y": + time.sleep(1) + os.system("clear") + print("Welcome!,Press Ctrl+C to quit") + # print("输入网络摄像头的用户名: ", end="") + # user = input() + user = "admin" + # print("输入网络摄像头密码:", end="") + # password = getpass.getpass() + password = "UMABQD" + # print("请输入网络摄像头的ip地址: ", end="") + # ip = input() + ip = "192.168.43.170" + print("你输入的内容为:"+user+":"+password+"@"+ip+",请检查!") + #print("是否继续?(Y/N)") + #passflag = input() + passflag = "y" + if passflag == "y" or passflag == "Y": + try: + print("开始") + i = 0 + while i!=4: + localtime = time.strftime("%H-%M-%S") + newtime = localtime.split('-') + sys.stdout.write("\r"+"Now time:"+str(newtime)) + sys.stdout.flush() + time.sleep(0.1) + if int(newtime[2])%10==0: + print() + get_image(user, ip, password) + print("图片获取完毕") + print("开始识别") + print() + sleepdict_end, student_attendancedict_end, student_id_list_actual = run_program(sleepdict,student_attendancedict) + print("识别结束 开始清除缓存") + time.sleep(1) + i = i + 1 + + reco_time = i + student_score_dict,student_headuprate_dict,student_id_headuprate_score_dict = GetJudge.each_student_headupRate(student_attendancedict_end,reco_time) + print("每个学生的抬头得分情况为:") + print(str(student_score_dict)) + print(str(student_headuprate_dict)) + print(str(student_id_headuprate_score_dict)) + except KeyboardInterrupt: + pass + else: + print("程序退出,欢迎使用!") + + else: + print("登陆失败") \ No newline at end of file diff --git a/app/testPost.py b/app/testPost.py new file mode 100644 index 0000000..f1795ae --- /dev/null +++ b/app/testPost.py @@ -0,0 +1,12 @@ +import requests + + +url = "http://47.103.14.73:8080/wisdom_web/monitorStudent/setStudentStatus" +# 1为睡觉 +# body = {"status":'1', "id":student_id} +# body = {"status":'1', "id":'41609030216'} +body = {"id":'1'} +response = requests.post(url,data=body) +print(response.text) + +print(response.status_code) \ No newline at end of file diff --git a/app/testSend.py b/app/testSend.py new file mode 100644 index 0000000..677b4b8 --- /dev/null +++ b/app/testSend.py @@ -0,0 +1,9 @@ +import requests +url = "http://47.103.14.73:8080/wisdom_web/monitorStudent/setStudentStatus" +# body = {"status":'1', "id":student_id} +# body = {"status":'2', "id":'41609030216'} +body = {"status":'1',"id":'41604090109'} +response = requests.post(url,data=body) +print(response.text) + +print(response.status_code) \ No newline at end of file diff --git a/faces/README.md b/faces/README.md new file mode 100644 index 0000000..5549183 --- /dev/null +++ b/faces/README.md @@ -0,0 +1 @@ +# 本文件夹存储每次识别所截取的临时脸部图像 \ No newline at end of file diff --git a/image/README.md b/image/README.md new file mode 100644 index 0000000..e3aff13 --- /dev/null +++ b/image/README.md @@ -0,0 +1 @@ +# 本文件夹存储用于识别的图像 \ No newline at end of file diff --git a/wisdom_android/README.md b/wisdom_android/README.md deleted file mode 100644 index 2bff5f6..0000000 --- a/wisdom_android/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# App设计模块——邹长林 - - diff --git a/wisdom_common/wisdom_common.iml b/wisdom_common/wisdom_common.iml deleted file mode 100644 index 19fb91a..0000000 --- a/wisdom_common/wisdom_common.iml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wisdom_manager/wisdom_manager.iml b/wisdom_manager/wisdom_manager.iml deleted file mode 100644 index 58d3c42..0000000 --- a/wisdom_manager/wisdom_manager.iml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wisdom_manager/wisdom_manager_dao/wisdom_manager_dao.iml b/wisdom_manager/wisdom_manager_dao/wisdom_manager_dao.iml deleted file mode 100644 index 681af3d..0000000 --- a/wisdom_manager/wisdom_manager_dao/wisdom_manager_dao.iml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wisdom_manager/wisdom_manager_interface/wisdom_manager_interface.iml b/wisdom_manager/wisdom_manager_interface/wisdom_manager_interface.iml deleted file mode 100644 index 7533759..0000000 --- a/wisdom_manager/wisdom_manager_interface/wisdom_manager_interface.iml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wisdom_manager/wisdom_manager_pojo/wisdom_manager_pojo.iml b/wisdom_manager/wisdom_manager_pojo/wisdom_manager_pojo.iml deleted file mode 100644 index 58d3c42..0000000 --- a/wisdom_manager/wisdom_manager_pojo/wisdom_manager_pojo.iml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wisdom_manager/wisdom_manager_service/wisdom_manager_service.iml b/wisdom_manager/wisdom_manager_service/wisdom_manager_service.iml deleted file mode 100644 index a15b93c..0000000 --- a/wisdom_manager/wisdom_manager_service/wisdom_manager_service.iml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wisdom_web/wisdom_web.iml b/wisdom_web/wisdom_web.iml deleted file mode 100644 index d1dde77..0000000 --- a/wisdom_web/wisdom_web.iml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file