va_test.cpp0 33.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864
#include <iostream>
#include <sstream>
#include <fstream>

#include "sy_common.h"
#include "sy_errorinfo.h"
#include "vehicle_analysis.h"
#include "vehicle_result.h"

#include "opencv2/opencv.hpp"
#include "opencv2/imgcodecs/legacy/constants_c.h"
#include "opencv2/imgproc/types_c.h"
#include "time.h"
#include "sys/time.h"

#include "utils.h"
#include "dvpp_process.h"

using namespace std;
using namespace cv;

#include <chrono>
#include <dirent.h>



//static char colorLabel[13][8] = { "棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑" };
static std::vector<std::string> CARCOLOR1 = {
	"BROWN","ORANGE","GRAY","WHITE","PINK","PURPLE","RED","GREEN","BLUE",
	"SILVER","CYAN","YELLOW","BLACK"
};

static char vsLabel[11][40] = { "diao", "guan",  "huo", "zha", "jiao","jiu",  "la", "xiao", "qing", "sui","wei" };


double msecond() {
    struct timeval tv;
    gettimeofday(&tv, 0);
    return (tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0);
}


void getAllNm(std::string pthNm, std::vector<std::string>& fileList)
{
        DIR    *dir;
    struct    dirent    *ptr;
    dir = opendir(pthNm.c_str()); ///open the dir
    int filenum = 0;
    while((ptr = readdir(dir)) != NULL) ///read the list of this dir
    {
        // char* to string
        std::string curNm = ptr->d_name;
        if(curNm != "." && curNm != "..")
        {
                filenum++;
                fileList.push_back(curNm);
                //printf("file %d name: %s\n", filenum, curNm.c_str());
        }
   }
    closedir(dir);
}


void CvBGR2NV21(Mat& bgr, unsigned char* yuv) {
    int stride = (bgr.cols + 127) / 128 * 128;
    int strideH = (bgr.rows + 15) / 16 * 16;
    for (int i = 0; i < bgr.rows; i++) {
        for (int j = 0; j < bgr.cols; j++) {
            int B = bgr.at<cv::Vec3b>(i, j)[0];
            int G = bgr.at<cv::Vec3b>(i, j)[1];
            int R = bgr.at<cv::Vec3b>(i, j)[2];

            int Y = (77 * R + 150 * G + 29 * B) >> 8;
            yuv[i * stride + j] = (Y < 0) ? 0 : ((Y > 255) ? 255 : Y);
            if (i % 2 == 0 && j % 2 == 0) {
                int U = ((-44 * R - 87 * G + 131 * B) >> 8) + 128;
                int V = ((131 * R - 110 * G - 21 * B) >> 8) + 128;
                yuv[strideH * stride + i / 2 * stride + j] = (V < 0) ? 0 : ((V > 255) ? 255 : V);
                yuv[strideH * stride + i / 2 * stride + j + 1] = (U < 0) ? 0 : ((U > 255) ? 255 : U);
            }
        }
    }
}







int main() {

	//ofstream oFile;
    //打开要输出的文件
    //oFile.open("va_result.csv", ios::out | ios::trunc);
	//oFile << "image" << "," << "image_quality_score" << "," << "count" << "," << "vehicle_info" << endl;


    cout << va_get_version() << endl;

	//string imagepath= "./vpt/";
	//string saveimagepath= "./result/";
	//int gpuid = 0;
		
	//string imagepath= "/home/HwHiAiUser/WH/vehicle_analysis202105/data/vpt/";
	//string imagepath= "/home/HwHiAiUser/WH/vehicle_analysis202105/data/bug/";
	string img_file_path= "/data/wanghong/Atlas310pro/vehicle_analysis202303/data/bug/";
	//string imagepath= "/home/HwHiAiUser/WH/vehicle_analysis202105/data/img/";
	//string imagepath= "/home/HwHiAiUser/WH/vehicle_analysis202105/data/carset/";
	string saveimagepath= "/data/wanghong/Atlas310pro/vehicle_analysis202303/data/result/";
	int gpuid = 0;
	
	va_param param;	
	param.vehicle_detect_config= SY_CONFIG_OPEN;  //1.开启车检测 SY_CONFIG_CLOSE  SY_CONFIG_OPEN
	param.vehicle_color_config= SY_CONFIG_OPEN;  //3.开启车颜色识别
	param.vehicle_recg_config= SY_CONFIG_OPEN;     //4.开启车型识别
	param.vehicle_recg_supplement_config= SY_CONFIG_OPEN;     //4.开启车型识别补充识别
	param.vehicle_plate_det_recg_config= SY_CONFIG_OPEN; //5.开启车牌检测识别	
	param.vehicle_pendant_det_config= SY_CONFIG_OPEN; //6.开启车属性检测识别	
	param.vehicle_illegal_config= SY_CONFIG_OPEN;  //7.开启车违规
	param.vehicle_feature_config= SY_CONFIG_OPEN;  //8.开启车辆特征提取
	param.vehicle_motor_tricycle_analysis_config= SY_CONFIG_OPEN;  //8.摩托车分析
	param.vehicle_manned_config= SY_CONFIG_OPEN;  //8.开启载人分析	
	
	
	param.gpuid=gpuid;
		
	//车检测参数	
	//param.vehicle_det_param.process_min_l = 720;// 720;
	//param.vehicle_det_param.process_max_l = 1280;//1280;	
	//param.vehicle_det_param.thresld=0.3;
	//param.min_obj_size=200;  //最小目标	
	param.vehicle_det_thresld=0.4;
	
	//车牌检测参数
	//param.vehicle_plate_det_param.process_min_l=320;
	//param.vehicle_plate_det_param.process_max_l=320;	
	//param.vehicle_plate_det_param.thresld=0.4;
	param.vehicle_plate_det_thresld=0.5;
	
	//车属性检测参数
	//param.vehicle_attribute_det_param.process_min_l=360;
	//param.vehicle_attribute_det_param.process_max_l=640;	
	//param.vehicle_attribute_det_param.thresld=0.3;
	param.vehicle_attribute_det_thresld=0.5;
	
	//车logo检测参数
	//param.vehicle_logo_det_param.process_min_l=512;
	//param.vehicle_logo_det_param.process_max_l=512;	
	//param.vehicle_logo_det_param.thresld=0.1;
	param.vehicle_logo_det_thresld=0.1;	
	
	//车颜色阈值
	param.vc_thresld = 0.5;
	
	//车型参数
	param.dbPath="/data/wanghong/Atlas310pro/vehicle_analysis202303/vehicle_analysis/db/vr_h0725x210605_r191230.db";	
	//param.dbPath="../db/vr_h0725x210605_r191230.db";
	
	param.models_Path="/data/wanghong/Atlas310pro/vehicle_analysis202303/vehicle_analysis/all_models/";	//所有模型的地址
    //param.models_Path="../modelsPath/";	//所有模型的地址
	
	
	int ret0= va_acl_init();
	
    void* handle = nullptr;	
    cout << "init start " << endl;
    int ret = va_init(&handle, param);
    if (ret == 0) {
        cout << "init success " << endl;
	}
	else
		return ret;
	
	
	
	
//	void* handle111 = nullptr;
//	cout << "init2 start " << endl;
//    int ret2 = va_init(&handle111, param);
//    if (ret2 == 0) {
//        cout << "init2 success " << endl;
//	}
//	else
//	{
//		cout << "init2 failed " << endl;
//		return ret2;
//	}
	
	
	
	double t3=0;
	int count =0;
	
//temp
    aclrtContext ctx;
	ACL_CALL(aclrtCreateContext(&ctx, gpuid), ACL_ERROR_NONE, SY_FAILED);
	ACL_CALL(aclrtSetCurrentContext(ctx), ACL_ERROR_NONE, SY_FAILED);
		
    aclrtStream stream = nullptr;
	ACL_CALL(aclrtCreateStream(&stream), ACL_ERROR_NONE, SY_FAILED);
    DvppProcess* dvpp = new DvppProcess();
	dvpp->InitResource(stream);

for(int iter =0;iter<100;iter++)
{	
	//ifstream infile("list.txt");	
	//ifstream infile("list_bug.txt");	
	//ifstream infile("list_700W.txt");
	//ifstream infile("list_img.txt");
	//string file;
	std::vector<std::string> fileList;
    getAllNm(img_file_path,fileList);
    if (fileList.empty()) throw std::logic_error("No suitable images were found");

		
    for (auto & file : fileList)
	{
        string filename = img_file_path + file;
		cout << "img path: " << filename << endl;
		const int batch_size = 1;
		printf("batch_size=%d \n",batch_size);

		Mat cvImg = imread(filename.c_str());
		sy_img imgs[batch_size];
	
		ACL_CALL(aclrtSetCurrentContext(ctx), ACL_ERROR_NONE, SY_FAILED);
		ImageData src[batch_size], dvpp_data[batch_size];
		if(1)
		{				 
			for (int b = 0; b < batch_size; b++) {
				Utils::ReadImageFile(src[b], filename); //将二进制图像读入内存,并读取宽高信息
				ACL_CALL(dvpp->CvtJpegToYuv420sp(dvpp_data[b], src[b]), SY_SUCCESS, SY_FAILED); //解码
				imgs[b].w_ = dvpp_data[b].width;//dvpp_data[b].alignWidth;
				imgs[b].h_ = dvpp_data[b].height;//dvpp_data[b].alignHeight;
				imgs[b].data_ = dvpp_data[b].data.get();//(uint8_t*)Utils::CopyDataDeviceToLocal(dvpp_data[b].data.get(), dvpp_data[b].size);
			}								
		}
		
		ImageData img_data_dvpp[batch_size];
		sy_img imgs_device[batch_size];
		if(0)
		{
			uint32_t alignWidth = (cvImg.cols + 127) / 128 * 128;
			uint32_t alignHeight = (cvImg.rows + 15) / 16 * 16;
			uint32_t size = alignWidth * alignHeight * 1.5;
			std::shared_ptr<uint8_t> data = shared_ptr<uint8_t>((new uint8_t[size]), 
				[](uint8_t* p) {delete [] p;});
			CvBGR2NV21(cvImg, data.get());
		 
			for (int i = 0; i < batch_size; i++) {
				imgs[i].w_ = cvImg.cols;
				imgs[i].h_ = cvImg.rows;
				imgs[i].data_ = data.get();
				//转到device输入
				Utils::CopysyImageDataToDvpp(img_data_dvpp[i], imgs[i]);
				imgs_device[i].w_ = img_data_dvpp[i].width;//dvpp_data[b].alignWidth;
				imgs_device[i].h_ = img_data_dvpp[i].height;//dvpp_data[b].alignHeight;
				imgs_device[i].data_ = img_data_dvpp[i].data.get();
			}				
		}
		
		if(0)
		{
			uint32_t alignWidth = (cvImg.cols + 127) / 128 * 128;
			uint32_t alignHeight = (cvImg.rows + 15) / 16 * 16;
			uint32_t size = alignWidth * alignHeight * 1.5;
			std::shared_ptr<uint8_t> data = shared_ptr<uint8_t>((new uint8_t[size]), 
				[](uint8_t* p) {delete [] p;});
			CvBGR2NV21(cvImg, data.get());
		 
			for (int i = 0; i < batch_size; i++) {
				imgs[i].w_ = cvImg.cols;
				imgs[i].h_ = cvImg.rows;
				imgs[i].data_ = data.get();
			}
			
		}
		
		count++;
		
		va_result *result=new va_result[batch_size];
		for(int b=0;b<batch_size;b++)
		{
			result[b].count=0;
			result[b].info=new vehicle_info[100];
			for(int c=0; c<100; c++)
			{
				result[b].info[c].vehicle_pendant_det_res.vpd_res=new v_pendant_d_info[300];	
			}			
		}
		
		double t1,t2;
		t1 = msecond();
		
		std::cout << "Predict----------------------------------"<< std::endl;			
		int ret = va_batch(handle, imgs, batch_size, result);
		//int ret = va_batch(handle, imgs_device, batch_size, result);
		t2 = msecond();
		printf("va_teat info:va_batch time: %.2f\n", (t2 - t1));	
		t3 += t2-t1;
		
		std::cout << "output----------------------------------"<< std::endl;
		
		for (int b = 0; b < batch_size; b++)
		{				
			if(param.vehicle_detect_config==SY_CONFIG_CLOSE)//不做车头检测时,应设result[b].count=1,即输入是车头图像,只含1辆车。
				result[b].count=1;
				
			//oFile << file << ","<< result[b].count<< "," <<endl;;	
			std::cout <<"car_count:" <<result[b].count<< std::endl;			
			for(int c=0;c<result[b].count;c++)
			{					
				//temp,中间结果,输出车牌被置黑的车小图
				//if(0)
				//{
				//	cv::Mat tmp(result[b].info[c].car_img_data_cpu[0].h_, result[b].info[c].car_img_data_cpu[0].w_, CV_8UC3, result[b].info[c].car_img_data_cpu[0].data_);
				//	char str_i[100];
				//	sprintf(str_i, "%d_",  c);
				//	cv::imwrite((save_folder_roi+str_i+i).c_str(),tmp);
				//}
				
				
				std::string str_vehicle_type;
				int vehicle_type=result[b].info[c].type;	
				//std::cout << "vehicle_type="<<vehicle_type<< std::endl;					
				if (vehicle_type==0)str_vehicle_type = "head";
				else if (vehicle_type==1)str_vehicle_type = "rear";
				else if (vehicle_type==2)str_vehicle_type = "motor";					
				else if (vehicle_type==3)str_vehicle_type = "tricycle";
				else if (vehicle_type==4)str_vehicle_type = "body";
				else if (vehicle_type==5)str_vehicle_type = "body_nova";
				std::cout << "		vehicle_type:"<<str_vehicle_type<< std::endl;
					
				//1.车头结果:蓝框//2.车窗结果:绿框
				if(param.vehicle_detect_config==SY_CONFIG_OPEN)
				{	
					//车身
					//std::cout << "vehicle_body_detect_res info:"<< std::endl;
					if(result[b].info[c].vehicle_body_detect_res.rect.width_>0)
					{
						float vehicle_body_detect_res_score = result[b].info[c].vehicle_body_detect_res.score;
						int x1=result[b].info[c].vehicle_body_detect_res.rect.left_;
						int y1=result[b].info[c].vehicle_body_detect_res.rect.top_;
						int x2=result[b].info[c].vehicle_body_detect_res.rect.left_+result[b].info[c].vehicle_body_detect_res.rect.width_;
						int y2=result[b].info[c].vehicle_body_detect_res.rect.top_+result[b].info[c].vehicle_body_detect_res.rect.height_;					
						std::cout << "		    vehicle_body_detect_res_score:" <<vehicle_body_detect_res_score<<",car_rect:[" <<x1<<"," <<y1<<"," <<x2-x1<<"," <<y2-y1<<"]"<< std::endl;
							
						Point lt(x1, y1);
						Point rb(x2, y2);
						rectangle(cvImg, lt, rb, cv::Scalar(0, 255,255), 4);						
					}	
					
					//车头
					//std::cout << "vehicle_detect_res info:"<< std::endl;
					if(result[b].info[c].vehicle_detect_res.rect.width_>0)	
					{						
						float vehicle_detect_res_score = result[b].info[c].vehicle_detect_res.score;
						int x1=result[b].info[c].vehicle_detect_res.rect.left_;
						int y1=result[b].info[c].vehicle_detect_res.rect.top_;
						int x2=result[b].info[c].vehicle_detect_res.rect.left_+result[b].info[c].vehicle_detect_res.rect.width_;
						int y2=result[b].info[c].vehicle_detect_res.rect.top_+result[b].info[c].vehicle_detect_res.rect.height_;										
						std::cout << "		    vehicle_detect_res_score:" <<vehicle_detect_res_score<<",car_rect:[" <<x1<<"," <<y1<<"," <<x2-x1<<"," <<y2-y1<<"]"<< std::endl;
							
						Point lt(x1, y1);
						Point rb(x2, y2);
						rectangle(cvImg, lt, rb, cv::Scalar(255, 0, 0), 4);	
					}
					
					//车窗
					//std::cout << "vwd output----"<< std::endl;
					if(result[b].info[c].vehicle_win_detect_res.rect.width_>0)
					{
						float vehicle_win_detect_res_score = result[b].info[c].vehicle_win_detect_res.score;
						int x1=result[b].info[c].vehicle_win_detect_res.rect.left_;
						int y1=result[b].info[c].vehicle_win_detect_res.rect.top_;
						int x2=result[b].info[c].vehicle_win_detect_res.rect.left_+result[b].info[c].vehicle_win_detect_res.rect.width_;
						int y2=result[b].info[c].vehicle_win_detect_res.rect.top_+result[b].info[c].vehicle_win_detect_res.rect.height_;					
						std::cout << "		    vehicle_win_detect_res_score:" <<vehicle_win_detect_res_score<<",win_rect:[" <<x1<<"," <<y1<<"," <<x2-x1<<"," <<y2-y1<<"]"<< std::endl;
							
						Point lt(x1, y1);
						Point rb(x2, y2);
						rectangle(cvImg, lt, rb, cv::Scalar(0, 255, 0), 4);
					}					
				}
		
				
				//3.车颜色
				if(param.vehicle_color_config==SY_CONFIG_OPEN&& (vehicle_type==0 || vehicle_type==1 || vehicle_type==4))
				{
					//std::cout << "vc output----"<< std::endl;
					int index=result[b].info[c].vehicle_color_res.index;
					float score=result[b].info[c].vehicle_color_res.score;
					
					if(score>0.5)
					{
						std::cout << "		car color info:"<< endl;
						std::cout << "		    index:"<< index<<" score:"<< score<< std::endl;
						
						std::string str_i = CARCOLOR1[index];
						cv::putText(cvImg, str_i,
							cv::Point(result[b].info[c].vehicle_body_detect_res.rect.left_+5, result[b].info[c].vehicle_body_detect_res.rect.top_+50),
							cv::FONT_HERSHEY_COMPLEX_SMALL,
							1.3,
							cv::Scalar(0, 0, 255),
							2);
					}
				}
				
				
				//4.VR车型识别
				if(param.vehicle_recg_config==SY_CONFIG_OPEN  && (vehicle_type==0 || vehicle_type==1 || vehicle_type==4 ))
				{
					//std::cout << "vr output----"<< std::endl;

					char *vehicle_brand=result[b].info[c].vehicle_recg_res.vehicle_brand;//车辆品牌
					char* vehicle_subbrand=result[b].info[c].vehicle_recg_res.vehicle_subbrand;             //车辆子品牌
					char* vehicle_issue_year=result[b].info[c].vehicle_recg_res.vehicle_issue_year;           //车辆年款
					char* vehicle_type_=result[b].info[c].vehicle_recg_res.vehicle_type;                //车辆类型
					char* freight_ton=result[b].info[c].vehicle_recg_res.freight_ton;                  //货车吨级
					float name_score=result[b].info[c].vehicle_recg_res.name_score;                   //识别置信度
					
					float name_score_thre = 0;
					//if(vehicle_type==0)name_score_thre=0.7;//车头车型识别建议阈值0.7
					//if(vehicle_type==1)name_score_thre=0.8;//车尾车型识别建议阈值0.8
					if(name_score > name_score_thre)
					{
						cout << "		vehicle_recg info: " << endl;
						std::cout << "			name_score: " << name_score << std::endl;
						std::cout << "			vehicle_brand: " << vehicle_brand << std::endl;
						std::cout << "			vehicle_subbrand: " << vehicle_subbrand << std::endl;
						std::cout << "			vehicle_issue_year: " << vehicle_issue_year << std::endl;
						std::cout << " 			vehicle_type_: " << vehicle_type_ << std::endl;
						std::cout << "			freight_ton: " << freight_ton << std::endl;

						//printf("name_score:%f\n", name_score);
						//printf("vehicle_brand:%s\n", vehicle_brand);
						//printf("vehicle_subbrand:%s\n", vehicle_subbrand);
						//printf("vehicle_issue_year:%s\n", vehicle_issue_year);
						//printf("vehicle_type_:%s\n", vehicle_type_);
						//printf("freight_ton:%s\n", freight_ton);
					}
				
				}
				
				
				//5.VP车牌检测识别
				if(param.vehicle_plate_det_recg_config==SY_CONFIG_OPEN  && (vehicle_type==0 || vehicle_type==1))
				{
					std::cout << "		car plate info:"<< endl;
					int special_type=result[b].info[c].vehicle_plate_det_recg_res.special_type;//常规车牌、临时车牌、低速车牌。0-common,1-temporary_license_plate,2-low_speed_license_plate.
					std::cout << "		    special_type:" << special_type<< std::endl;
					
					float detect_score=result[b].info[c].vehicle_plate_det_recg_res.detect_score;
					//std::cout << "detect_score:" << detect_score<< std::endl;
					if(detect_score>0.3)
					{						
						int type=result[b].info[c].vehicle_plate_det_recg_res.type;
						sy_rect rect=result[b].info[c].vehicle_plate_det_recg_res.rect;
						
						int x1=rect.left_;
						int y1=rect.top_;
						int x2=rect.left_+rect.width_;
						int y2=rect.top_+rect.height_;		
						std::cout << "		    vp_type:"<<type<<",vp_det_score:" <<detect_score <<",vp_rect:[" <<x1<<"," <<y1<<"," <<x2-x1<<"," <<y2-y1<<"]"<< std::endl;													
						
						Point lt(x1, y1);
						Point rb(x2, y2);
						rectangle(cvImg, lt, rb, cv::Scalar(0, 0, 255), 4);
							
							
						
						//车牌识别结果
						float num_score=result[b].info[c].vehicle_plate_det_recg_res.num_score;
						std::string plate_recg="";
						//if(num_score>0.99)//车牌识别建议置信度阈值0.99
						{
							
							//printf("plate: ");
							for (int m = 0; m < PLATENUM; m++)
							{
								//printf("%s", result[b].info[c].vehicle_plate_det_recg_res.recg[m].character);
								plate_recg=plate_recg + result[b].info[c].vehicle_plate_det_recg_res.recg[m].character;
							}
							//printf("\n");
							
							//printf("maxprob: ");
							//for (int m = 0; m < PLATENUM; m++)
							//{
							//	printf("%f ", result[b].info[c].vehicle_plate_det_recg_res.vehicle_plate_infos[0].recg[m].maxprob);
							//}
							//printf("\n");

							
							//std::cout << "type:" << type<<"  num_score:" <<num_score<<"  " << std::endl;
							std::cout <<"		    "<<plate_recg<< ",vp_num_score:" << num_score<< std::endl;
								
						}
						
						
						char str_cc[100];
						memset(str_cc, 0, sizeof(str_cc));
						cv::Point2f p1;
						p1.x = x1;
						p1.y = y1-60;
						//sprintf(str_cc, "det_%.2f_recg_%.2f_%s",detectScore,numScore,plate_recg.c_str()); 
						sprintf(str_cc, "det_%.2f",detect_score); 
						cv::putText(cvImg, str_cc, 
						  p1,
						  cv::FONT_HERSHEY_COMPLEX_SMALL,
						  1.3,
						  cv::Scalar(0, 0, 255),
						  2);
						  
						memset(str_cc, 0, sizeof(str_cc));
						p1.x = x1;
						p1.y = y1-30;
						sprintf(str_cc, "recg_%.2f",num_score); 
						cv::putText(cvImg, str_cc, 
						  p1,
						  cv::FONT_HERSHEY_COMPLEX_SMALL,
						  1.3,
						  cv::Scalar(0, 0, 255),
						  2);
						 
						memset(str_cc, 0, sizeof(str_cc));
						p1.x = x1;
						p1.y = y1;
						sprintf(str_cc, "%s",plate_recg.c_str()); 
						cv::putText(cvImg, str_cc, 
						  p1,
						  cv::FONT_HERSHEY_COMPLEX_SMALL,
						  1.3,
						  cv::Scalar(0, 0, 255),
						  2);

					}
					
				}
				
				//6.车属性结果:
				if(param.vehicle_pendant_det_config==SY_CONFIG_OPEN && (vehicle_type==0|| vehicle_type==4))
				{
					std::cout << "		vehicle_pendant_det_res info:"<< endl;
					int vpd_num = result[b].info[c].vehicle_pendant_det_res.count;
					//std::cout << vpd_num<< std::endl;
					std::cout << "		    vpd_num:"<<vpd_num<< endl;
					for(int p=0; p<vpd_num; p++)
					{
						int index = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].index;
						float detect_score = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].confidence;
						int driver_copilot_info = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].driver_copilot_info;
						int x1=result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.left_;
						int y1=result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.top_;
						int x2=result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.left_+result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.width_;
						int y2=result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.top_+result[b].info[c].vehicle_pendant_det_res.vpd_res[p].rect.height_;					
		
						//std::cout <<p<<" ["<<x1<<" "<<y1<<" "<<x2-x1<<" "<<y2-y1<<"] "<<detectScore<<" "<<index<<" "<<driver_copilot_info<< std::endl;
						std::cout << "		    vpd id:"<<p<<" index:"<<index<<",vpd_det_score:" <<detect_score <<",vpd_rect:[" <<x1<<"," <<y1<<"," <<x2-x1<<"," <<y2-y1<<"]"<<" driver_copilot_info:"<<driver_copilot_info<< std::endl;
							
						
						Point lt(x1, y1);
						Point rb(x2, y2);
						rectangle(cvImg, lt, rb, cv::Scalar(255, 255, 0), 4);
						
						//车属性人脸特征
						//f(index ==1)//人脸
						//{
						//	std::cout << "		    vpd face feature:[";
						//	/*for(int f=0;f<VPD_FACE_FEATURESIZE;f++)
						//	{
						//		float fea = result[b].info[c].vehicle_pendant_det_res.vpd_res[p].feature[f];
						//		//std::cout << "feature "<<f<<":"<<fea<<std::endl; 
						//		std::cout <<fea<< " ";
						//	}*/
						//	std::cout << "]"<< std::endl;
						//	//std::cout << "face feature:"<<result[b].info[c].vehicle_pendant_det_res.vpd_res[p].feature[0]<<" "<<result[b].info[c].vehicle_pendant_det_res.vpd_res[p].feature[1]<<" "<<result[b].info[c].vehicle_pendant_det_res.vpd_res[p].feature[2]<<std::endl; 
						//}						
					}
				}
				
				//7.VID车违规结果-----------
				if(param.vehicle_illegal_config==SY_CONFIG_OPEN  && vehicle_type==0)
				{		
					std::cout << "		vehicle_illegal_det_res info:"<< endl;
					vid_result cur_result = result[b].info[c].vehicle_illegal_det_res;
					//副驾驶copilot
					{
						//有人没人判断,阈值0.6
						std::string str_person="UNCERTAINTY";
						if(cur_result.copilot.person.status==SOMEBODY)
							str_person ="PERSON";
						else if(cur_result.copilot.person.status==NOBODY)
							str_person ="NOPERSON";				
						//cv::putText(batch_mat[b], str_person, 
						//	  cv::Point(5, 25),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
						
						//打电话,阈值0.9
						std::string str_call="UNCERTAINTY";
						if(cur_result.copilot.call.status==lEGAL)
							str_call ="lEGAL";//str_call ="NOCALL";
						else if(cur_result.copilot.call.status==ILLEGAL)
							str_call ="ILLEGAL";//str_call ="CALL";
						//cv::putText(batch_mat[b], str_call, 
						//	  cv::Point(5, 50),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
							  
						//使用电话、阈值0.89
						std::string str_phone="UNCERTAINTY";
						if(cur_result.copilot.phone.status==lEGAL)
							str_phone ="lEGAL";//str_phone ="NOPHONE";
						else if(cur_result.copilot.phone.status==ILLEGAL)
							str_phone ="ILLEGAL";//str_phone ="USEPHONE";
						//cv::putText(batch_mat[b], str_phone, 
						//	  cv::Point(5, 75),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
						
						//系安全带,阈值0.5
						std::string str_belt="UNCERTAINTY";
						if(cur_result.copilot.belt.status==lEGAL)
							str_belt ="lEGAL";//str_belt ="SAFETYBELT";
						else if(cur_result.copilot.belt.status==ILLEGAL)
							str_belt ="ILLEGAL";

						//cv::putText(batch_mat[b], str_belt, 
						//	  cv::Point(5, 75),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
							  
						//抽烟,阈值0.9
						std::string str_smoke="UNCERTAINTY";
						if(cur_result.copilot.smoke.status==ILLEGAL)
							str_smoke ="ILLEGAL";//str_smoke ="SMOKE";
						else if(cur_result.copilot.smoke.status==lEGAL)
							str_smoke ="lEGAL";//str_smoke ="NOSMOKE";
						//cv::putText(batch_mat[b], str_smoke, 
						//	  cv::Point(5, 100),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);

						//std::cout << "copilot: "<<str_person<< " "<<str_call<< " "<<str_phone<< " "<<str_belt<< " "<<str_smoke<< std::endl;						
						//std::cout << "copilot confidence: "<<cur_result.copilot.person.confidence<< " "<<cur_result.copilot.call.confidence<< " "<<cur_result.copilot.phone.confidence<< " "<<cur_result.copilot.belt.confidence<< " "<<cur_result.copilot.smoke.confidence<< std::endl;
					    std::cout << "		    copilot:  "<<"person:"<<str_person<< " call:"<<str_call<< " phone:"<<str_phone<< " belt:"<<str_belt<< " smoke:"<<str_smoke<< std::endl;						
					    std::cout << "		    copilot confidence:  "<<"person:"<<cur_result.copilot.person.confidence<< " call:"<<cur_result.copilot.call.confidence<< " phone:"<<cur_result.copilot.phone.confidence<< " belt:"<<cur_result.copilot.belt.confidence<< " smoke:"<<cur_result.copilot.smoke.confidence<< std::endl;
						
					}
					
					//驾驶driver
					{
						//有人没人判断,阈值0.6
						std::string str_person="UNCERTAINTY";
						if(cur_result.driver.person.status==SOMEBODY)
							str_person ="PERSON";
						else if(cur_result.driver.person.status==NOBODY)
							str_person ="NOPERSON";				
						//cv::putText(batch_mat[b], str_person, 
						//	  cv::Point(5, 150),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
						
						//打电话,阈值0.9
						std::string str_call="UNCERTAINTY";
						if(cur_result.driver.call.status==lEGAL)
							str_call ="lEGAL";//str_call ="NOCALL";
						else if(cur_result.driver.call.status==ILLEGAL)
							str_call ="ILLEGAL";//str_call ="CALL";
						//cv::putText(batch_mat[b], str_call, 
						//	  cv::Point(5, 175),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
							  
						//使用电话,阈值0.89
						std::string str_phone="UNCERTAINTY";
						if(cur_result.driver.phone.status==lEGAL)
							str_phone ="lEGAL";//str_phone ="NOPHONE";
						else if(cur_result.driver.phone.status==ILLEGAL)
							str_phone ="ILLEGAL";//str_phone ="USEPHONE";
						//cv::putText(batch_mat[b], str_phone, 
						//	  cv::Point(5, 200),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
						
						//系安全带,阈值0.5
						std::string str_belt="UNCERTAINTY";
						if(cur_result.driver.belt.status==lEGAL)
							str_belt ="lEGAL";//str_belt ="SAFETYBELT";
						else if(cur_result.driver.belt.status==ILLEGAL)
							str_belt ="ILLEGAL";//str_belt ="NOSAFETYBELT";

						//cv::putText(batch_mat[b], str_belt, 
						//	  cv::Point(5, 200),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
							  
						//抽烟,阈值0.9
						std::string str_smoke="UNCERTAINTY";
						if(cur_result.driver.smoke.status==ILLEGAL)
							str_smoke ="ILLEGAL";//str_smoke ="SMOKE";
						else if(cur_result.driver.smoke.status==lEGAL)
							str_smoke ="lEGAL";//str_smoke ="NOSMOKE";
						//cv::putText(batch_mat[b], str_smoke, 
						//	  cv::Point(5, 225),
						//	  cv::FONT_HERSHEY_COMPLEX_SMALL,
						//	  1.3,
						//	  cv::Scalar(255, 0, 0),
						//	  2);
						
						//std::cout << "driver: "<<str_person<< " "<<str_call<< " "<<str_phone<< " "<<str_belt<< " "<<str_smoke<< std::endl;
						//std::cout << "driver confidence: "<<cur_result.driver.person.confidence<< " "<<cur_result.driver.call.confidence<< " "<<cur_result.driver.phone.confidence<< " "<<cur_result.driver.belt.confidence<< " "<<cur_result.driver.smoke.confidence<< std::endl;
					     std::cout << "		    driver:  person:"<<str_person<< " call:"<<str_call<< " phone:"<<str_phone<< " belt:"<<str_belt<< " smoke:"<<str_smoke<< std::endl;
						std::cout << "		    driver confidence:  person:"<<cur_result.driver.person.confidence<< " call:"<<cur_result.driver.call.confidence<< " phone:"<<cur_result.driver.phone.confidence<< " belt:"<<cur_result.driver.belt.confidence<< " smoke:"<<cur_result.driver.smoke.confidence<< std::endl;
						
					}				
				}
				
				
				
				
				//8.车特征
				if(param.vehicle_feature_config==SY_CONFIG_OPEN && (vehicle_type==0 || vehicle_type==1))
				{
					std::cout << "		vehicle_fea_res info: "<<std::endl;
					std::cout << "		    [";	
					for(int f=0;f<VA_FEATURESIZE;f++)
					{
						float fea=result[b].info[c].vehicle_fea_res.feature[f];
						//std::cout << "feature "<<f<<":"<<fea<<std::endl; 
						std::cout <<fea<<" ";
					}
					std::cout <<"]"<<std::endl;
					//std::cout << "feature 0 :"<<result[b].info[c].vehicle_fea_res.feature[0]<<std::endl; 
					//std::cout << "feature 1 :"<<result[b].info[c].vehicle_fea_res.feature[1]<<std::endl; 
					//std::cout << "feature 2 :"<<result[b].info[c].vehicle_fea_res.feature[2]<<std::endl; 
					//std::cout << "feature 3 :"<<result[b].info[c].vehicle_fea_res.feature[3]<<std::endl; 
					//std::cout << "feature 4 :"<<result[b].info[c].vehicle_fea_res.feature[4]<<std::endl; 
					//std::cout << "feature 5 :"<<result[b].info[c].vehicle_fea_res.feature[5]<<std::endl; 
					
					//test
					//for(int f=0;f<10;f++)
					//{
					//	float fea=result[b].info[c].vehicle_fea_res.feature[f];
					//	std::cout << "feature "<<f<<":"<<fea<<std::endl; 
					//}
				}

				//11.摩托车三轮车分析
				 if(param.vehicle_motor_tricycle_analysis_config==SY_CONFIG_OPEN && (vehicle_type==2 || vehicle_type==3))
				 {
					 //std::cout << "mta output----"<< std::endl;
					 
					 if(vehicle_type==2)//摩托车
					 {
						//摩托车载人
						//int status=result[b].info[c].mta_res.motor_manned.status;	
						//float score=result[b].info[c].mta_res.motor_manned.confidence;
						//if(status == MOTOR_MANNED)
						//	std::cout << "motor info: MOTOR_MANNED, prob: " << score << std::endl;
						//else if(status == MOTOR_NOT_MANNED)
						//	std::cout << "motor info: MOTOR_NOT_MANNED, prob: " << score << std::endl;
						
						//摩托车驾驶人是否戴安全帽
						int status=result[b].info[c].mta_res.motor_driver_helmeted.status;
						float score=result[b].info[c].mta_res.motor_driver_helmeted.confidence;
						if(status == MOTOR_DRIVER_HELMETED)
							std::cout << "		    motor info: MOTOR_DRIVER_HELMETED, prob: " << score << std::endl;
						else if(status == MOTOR_DRIVER_NOT_HELMETED)
							std::cout << "		    motor info: MOTOR_DRIVER_NOT_HELMETED, prob: " << score << std::endl;	
						
					 }
				 }
							 //载人输出
				//if(param.vehicle_manned_config==SY_CONFIG_OPEN && (vehicle_type==0 || vehicle_type==1 || vehicle_type==3))
				if(param.vehicle_manned_config==SY_CONFIG_OPEN && vehicle_type!=5)
				{
					std::cout << "----------------------manned output----"<< std::endl;
					int hs_count = result[b].info[c].manned_res.hs_count;
					std::cout <<"manned_hs_count:"<< hs_count << std::endl;
					for(int lo=0;lo<hs_count;lo++)
					{
						int x1=result[b].info[c].manned_res.hs_rect[lo].rect.left_;
						int y1=result[b].info[c].manned_res.hs_rect[lo].rect.top_;
						int x2=result[b].info[c].manned_res.hs_rect[lo].rect.left_+result[b].info[c].manned_res.hs_rect[lo].rect.width_;
						int y2=result[b].info[c].manned_res.hs_rect[lo].rect.top_+result[b].info[c].manned_res.hs_rect[lo].rect.height_;					

						std::cout <<"manned_hs_rect:"<< x1 <<" "<< y1<<" " <<x2<<"  " << y2<< std::endl;
						
						Point lt(x1, y1);
						Point rb(x2, y2);
						rectangle(cvImg, lt, rb, cv::Scalar(0, 255, 255), 4);
					}						
				}				
			}

			//测试相似度比对函数,batch_size设为2
			//double similarity=va_compute_similarity(result[0].info[0].vehicle_fea_res.feature, result[1].info[0].vehicle_fea_res.feature, FEATURESIZE);
			//std::cout << "similarity: "<<similarity<<std::endl; 
			
			
			
			//cv::Mat showImg;
			//showImg=batch_mat[b].clone();
			//cv::resize(batch_mat[b], showImg, cv::Size(batch_mat[b].cols/2,batch_mat[b].rows/2));
			//cv::imshow("image", showImg);
			//cv::waitKey(0);			
			cv::imwrite((saveimagepath+file).c_str(),cvImg);
													 
		}
		

			


		
		//delete result
		for(int b=0;b<batch_size;b++)
		{
			for(int c=0; c<100; c++)
			{
				if(result[b].info[c].vehicle_pendant_det_res.vpd_res!=NULL)
					delete[] result[b].info[c].vehicle_pendant_det_res.vpd_res;
				
			}
			if(result[b].info!=NULL)
			   delete[] result[b].info;
		}
		if(result!=NULL)
			   delete[] result;

	} 
}
	
	std::cout << "va_release---------------------"<< std::endl;
    va_release(&handle);
	//va_release(&handle111);
	va_acl_release();
 
	printf("va_teat info:va_batch time: t3=%.2f\n", t3/count);
	
	//oFile.close();
		
    return 0;
}