int main(int argc, char *argv[]) {
    int width, height ,mode,flag;    
    aml_image_info_t* image_info;    
    char* p;
    if(argc < 5){        
        printf("Amlogic raw decoder API \n");
        printf("usage: output [filename] [width] [height] [mode]\n");
        printf("options :\n");
        printf("         filename : raw url in your root fs\n");
        printf("         width    : output width\n");
        printf("         height   : output height\n");
        printf("         mode     : 0/keep ratio  1/crop image 2/stretch image\n");
        printf("         flag     : 0/disable display  1/enable display\n");
        return -1;    
    }else{
        printf("%s\n", argv[1]);
    }   
    image_info = read_raw_image(argc, argv);
    
    if(image_info){
        printf("output image width is %d\n", image_info->width);
        printf("output image height is %d\n", image_info->height);
        printf("output image depth is %d\n", image_info->depth);
        printf("output image bytes_per_line is %d\n", image_info->bytes_per_line);
        printf("output image nbytes   is %d\n", image_info->nbytes);
    }
    if(image_info){
        free(image_info);    
        image_info = NULL;
    }    
    return 0;
}
Beispiel #2
0
image_type read_image(const std::string& url, const std::string& format_hint) {
  image_type img;
  char* data;
  read_raw_image(url, &data, img.m_image_data_size,
      img.m_width, img.m_height, img.m_channels,
      img.m_format, format_hint);
  img.m_image_data.reset(data);
  return img;
}
void reset_values()
{
    delete(meet);
    delete(image);
    image = (char*)malloc(sizeof(char)*image_height*image_width);
    read_raw_image("image.raw",image,image_height,image_width);

    meet=(ConsensusGrid*)malloc(sizeof(ConsensusGrid)*image_height*image_width);
    basis = (int*)malloc(sizeof(int)*image_height*image_width);
    not_null_count = 0;
    basis_count = 0;
}
Beispiel #4
0
int main(int argc, char** argv)
{
	if(argc > 3)
	{
		image_height=atoi(argv[1]);
		image_width=atoi(argv[1]);
		if(atoi(argv[2]) == 1)
			create_image();

		image = (char*)malloc(sizeof(char)*image_height*image_width);
		meet=(ConsensusGrid*)malloc(sizeof(ConsensusGrid)*image_height*image_width);
		basis = (int*)malloc(sizeof(int)*image_height*image_width);

		read_raw_image("image.raw",image,image_height,image_width);
		for(int i=0; i<image_height; i++)
		{
			for(int j = 0; j<image_width; j++)
			{
				if(atoi(argv[3]) == 1)
					meet[i*image_width+j]=consensus_parallel(i, j, image,image_height,image_width);
				else
					meet[i*image_width+j]=consensus(i, j, image,image_height,image_width);
			}
		}

		printf("Calculating list\n");
		if(atoi(argv[3]) == 1)
			calculate_list_parallel();
		else
			calculate_list();

		printf("Calculating basis\n");
		if(atoi(argv[3]) == 1)
			calculate_basis_parallel();
		else
			calculate_basis();

		cout << "Basis count = " << basis_count << endl;
	}

	else
	{
		cout << "Insufficient arguments\n" << endl;
		cout << "First argument = Image Size" << endl;
		cout << "Second argument = 1 to create image, 0 not to create image" << endl;
		cout << "Third argument = 1 for parallel, 0 for not parallel\n" << endl;
	}
}
int nandroid_backup_flags(const char* backup_path, int flags)
{
    ui_set_background(BACKGROUND_ICON_INSTALLING);
    
    if (ensure_root_path_mounted("SDCARD:") != 0)
        return print_and_error("Can't mount /sdcard\n");
    
    int ret;
    struct statfs s;
    if (0 != (ret = statfs("/sdcard", &s)))
        return print_and_error("Unable to stat /sdcard\n");
    uint64_t bavail = s.f_bavail;
    uint64_t bsize = s.f_bsize;
    uint64_t sdcard_free = bavail * bsize;
    uint64_t sdcard_free_mb = sdcard_free / (uint64_t)(1024 * 1024);
    ui_print("SD Card space free: %lluMB\n", sdcard_free_mb);
    if (sdcard_free_mb < 150)
        ui_print("There may not be enough free space to complete backup... continuing...\n");
    
    char tmp[PATH_MAX];
    sprintf(tmp, "mkdir -p %s", backup_path);
    __system(tmp);

#ifndef BOARD_RECOVERY_IGNORE_BOOTABLES
    ui_print("Backing up boot...\n");
    sprintf(tmp, "%s/%s", backup_path, "boot.img");
    ret = read_raw_image("boot", tmp);
    if (0 != ret)
        return print_and_error("Error while dumping boot image!\n");

    ui_print("Backing up recovery...\n");
    sprintf(tmp, "%s/%s", backup_path, "recovery.img");
    ret = read_raw_image("recovery", tmp);
    if (0 != ret)
        return print_and_error("Error while dumping recovery image!\n");
#endif

    if (0 != (ret = nandroid_backup_partition(backup_path, "SYSTEM:")))
          return ret;

    if (0 != (ret = nandroid_backup_partition(backup_path, "DATA:")))
        return ret;

#ifdef HAS_DATADATA
    if (0 != (ret = nandroid_backup_partition(backup_path, "DATADATA:")))
        return ret;
#endif

    struct stat st;
      if (0 != stat("/sdcard/.android_secure", &st))
      {
          ui_print("No /sdcard/.android_secure found. Skipping backup of applications on external storage.\n");
      }
      else
      {
          if (0 != (ret = nandroid_backup_partition_extended(backup_path, "SDCARD:/.android_secure", 0)))
              return ret;
    }

    if (0 != (ret = nandroid_backup_partition_extended(backup_path, "CACHE:", 0)))
        return ret;

      if (0 != stat(SDEXT_DEVICE, &st))
      {
          ui_print("No sd-ext found. Skipping backup of sd-ext.\n");
      }
      else
      {
          if (0 != ensure_root_path_mounted("SDEXT:"))
              ui_print("Could not mount sd-ext. sd-ext backup may not be supported on this device. Skipping backup of sd-ext.\n");
          else if (0 != (ret = nandroid_backup_partition(backup_path, "SDEXT:")))
              return ret;
    }

    ui_print("Generating md5 sum...\n");
    sprintf(tmp, "nandroid-md5.sh %s", backup_path);
    if (0 != (ret = __system(tmp))) {
        ui_print("Error while generating md5 sum!\n");
        return ret;
    }
    
    sync();
    ui_set_background(BACKGROUND_ICON_EBCLOCKWORK);
    ui_reset_progress();
    ui_print("\nBackup complete!\n");
    return 0;
}
Beispiel #6
0
// {{{ mjpg_cam_covered()
int mjpg_cam_covered(const char *host, const char *url, size_t port, 
					 const char *credentials, int threshold, int cnt_imgs)
{
	int sockfd = socket_open(host, url, port, credentials);
	
    if (sockfd <= 0)
		return -1;
	
    char line[128];
	int nbytes=0;
	int len = 0;
	
	/* find initial position */
	while((nbytes = recvline(line, sizeof(line), sockfd))>=0)
	{
		if(strstr(line, "Content-Type") || strstr(line, "--BoundaryString"))
		{
		//	write(1, line, strlen(line));
		//	write(1, "\r\n", 2);
			break;
		}
	}
	return_if_fail(nbytes);
	
	/* image frames */
	image_t *frm1 = NULL;
	int cnt_images=0;

	int cnt = 0;
	
	while(cnt < cnt_imgs)
	{
		char boundary[64] = "";
		char ct[64] = "";
		char cl[64] = "";
		len = find_next_frame(sockfd, boundary, sizeof(boundary), 
				ct, sizeof(ct), cl, sizeof(cl));
		goto_error_if_fail(len);


		/* read image */
		//len += 2;
		char img[len];
		size_t total_bytes = read_raw_image(img, len, sockfd);		
		goto_error_if_fail(total_bytes);
		
		cnt_images++;		
		int res=0;

		frm1 = jpeg_read(img, total_bytes);
		if(!frm1)
			goto error;
		
		/* check if the camera is covered */
		res = image_pixel_diff(frm1, threshold);
		
		/* if the camera is covered we return 1 */
		if(res > 0)
		{
			image_free(frm1);
			close(sockfd);
			return res;
		}
			
		image_free(frm1);

		cnt++;
	}
		
	close(sockfd);
	return 0;

error:
	close(sockfd);
	return -10;
	
}
Beispiel #7
0
// {{{ mjpg_streaming()
int mjpg_streaming(mjpg_t *p)
{
	if(!p)
		return -1;

	int recording_fd=0;
	int fps_fd=0;
	int frames_cnt=0;
	time_t frames_tm=time(NULL);
	char line[128];
	int nbytes=0;
	int r;
	int len = 0;
	int fd = -1;
	int flags = p->flags;
	char * base = p->base;
	int threshold = p->threshold;
	float fps=0;
	char buf[256];
	/* true if are set zones*/
	int set_zones = 0;
	int i = 0;

	if(signal(SIGTERM, signal_handler)==SIG_ERR)
		return -1;
	
	if(signal(SIGINT, signal_handler)==SIG_ERR)
		return -1;


	// Use socket as source of streaming
	if(flags & M_READ_FROM_SOCKET)
	{
	  	syslog(LOG_NOTICE, "Read streaming from socket\n");
		fd = socket_open(p->host, p->url, p->port, p->auth);
		if(fd<0)
	  		syslog(LOG_NOTICE, "error %d opening socket\n", fd);
	
	}		

	// Use file as source of streaming
	if(flags & M_READ_FROM_FILE)
	{
	  	syslog(LOG_NOTICE, "Read streaming from file\n");
		fd = file_open(p->src_file);

		// Read frames per second
		char filename[128];
		str_assign_str(filename, sizeof(filename), p->src_file);
		str_replace(filename, sizeof(filename), ".mjpg", ".fps");
		int fdtmp = open(filename, O_RDONLY);
		if(fdtmp<0)
		{
	  		syslog(LOG_ERR, "Cannot open file: %s\n", filename);
			goto error;
		}
		char buffer[32];
		if((read(fdtmp, buffer, sizeof(buffer)))>0)
		{
			fps=atof(buffer);
	  		syslog(LOG_NOTICE, "fps:%s=%f\n", buffer, fps);
		}
		
		close(fdtmp);

	}

	if(fd<=0)
	{
	  	syslog(LOG_ERR, "Cannot read streaming source\n");
		return -1;
	}


	// Move reading pointer to specified position
	if((flags & M_READ_FROM_FILE) && (flags & M_OFFSET))
	{	
		syslog(LOG_DEBUG, "play from position: %d\n", p->offset);
		jump_to(fd, p->offset);
	}

	/* Check set zones */
	for (i = 0; i < MAX_ZONES; i++) {
		if(p->zones[i].x_top_left != 0 || p->zones[i].x_bottom_right != 0 || 
		   p->zones[i].y_top_left != 0 || p->zones[i].y_bottom_right != 0)
		{
			set_zones = 1;
			break;
		}
	}
	
	/* image frames */
	image_t *frm1 = NULL;
	image_t *frm2 = NULL;
	int cnt_images=0;
	int record_in_file=0;
	char path_mjpg[128];
	char path_jpg[128];
	char path_fps[128];
	time_t t=0;
	int has_header=0;

	char boundary[64] = "--odboundary";



	while(1)
	{
		if(stop)
		{
			syslog(LOG_NOTICE, "stopping...\n");
			goto error;
		}

		/* find initial position */
		char ct[64] = "";
		char cl[64] = "";

		len = find_next_frame(fd, boundary, sizeof(boundary), 
				ct, sizeof(ct), cl, sizeof(cl));

		if(len==0)
		{
			syslog(LOG_DEBUG, "unknown content length. force to %d\n", 50000);
			len=50000;
		}
	


		/* if video position is too long, find last frame */
		int try=0;
		off_t offset = p->offset;
			
		if(flags & M_READ_FROM_FILE)
		{
			while(len<0 && cnt_images==0 && try<20)
			{
				offset -= 5;
				syslog(LOG_DEBUG, "play from another position: %d\n", offset);
				jump_to(fd, offset);
				try++;
				len = find_next_frame(fd, boundary, sizeof(boundary), 
						ct, sizeof(ct), cl, sizeof(cl));
			}
		}

		goto_error_if_fail(len);

		// write header
		if((flags & M_STDOUT) && !has_header)
		{
			char *http_str = 
				"Content-Type: multipart/x-mixed-replace; boundary=";
			write(1, http_str, strlen(http_str));		
			write(1, boundary, strlen(boundary));		
			write(1, "\r\n", 2);
			write(1, "\r\n", 2);
			has_header=1;
		}

		/* read image */
		//len += 2;
		char img[len*2];
		size_t total_bytes = read_raw_image(img, len, fd);		
		//syslog(LOG_DEBUG, "image read with %d bytes\n", total_bytes);
		goto_error_if_fail(total_bytes);

		cnt_images++;		

		if(flags & M_READ_FROM_SOCKET)
		{
			// Draw timestamp
			image_t *frm = jpeg_read(img, total_bytes);
			if(!frm)
				goto error;

			point_t pt;
			pt.x = 10;
			pt.y = 10;
			time_t t = time(NULL);
			//image_draw_text(frm1, "OpenDomo Video System", &pt);	
			//pt.y = 25;			
			image_draw_text(frm, ctime(&t), &pt);				
			unsigned long imgbuf_len = 0;
			char *imgbuf = jpeg_write_alloc(frm, 75, &imgbuf_len);

			if(len*2<imgbuf_len)	
			{
				syslog(LOG_ERR, "Cannot draw text. Buffer too short\n");
			}
			else
			{
				memcpy(img, imgbuf, imgbuf_len);
				len = imgbuf_len;
			}

			free(imgbuf);
			image_free(frm);
		}


		// get separated frames
		int diff=0;
		if(threshold>0)
		{
			if(cnt_images%2==1)
			{
				frm1 = jpeg_read(img, total_bytes);
				if(!frm1)
					goto error;
			}
			else
			{
				frm2 = jpeg_read(img, total_bytes);

				if(!frm2)
				{
					image_free(frm1);
					goto error;
				}

				// processing between frames
				if(flags & M_DRAW_SHAPE)	
				{		
					// TODO
				}
				if(set_zones == 0)
					diff = image_num_diff(frm1, frm2);
				else
				{
					for (i = 0; i < MAX_ZONES; i++) {
						if(p->zones[i].x_top_left != 0 || 
						   p->zones[i].x_bottom_right != 0 || 
						   p->zones[i].y_top_left != 0 || 
						   p->zones[i].y_bottom_right != 0)
						{
							diff = image_num_diff_zone(frm1, frm2,  &p->zones[i]);
							if (diff>threshold)
								break;
						}
					}
				}


				image_free(frm1);
				image_free(frm2);
			}
		}


		// When recording begins we need to create an image with the first 
		// frame of the streaming and to write the header of the mjpg stream.
		if(record_in_file == 0)
		{
			if((flags & M_RECORD))
				record_in_file = 1;

			if((diff>threshold) && (flags & M_RECORD_THRESHOLD))
				record_in_file = 1;

			if(record_in_file==1)
			{
				t = time(NULL);
				syslog(LOG_NOTICE, "recording: %d\n", t);
				char timestamp[16];
				strftime(timestamp, sizeof(timestamp), "%Y%m%d%H%M%S", 
						localtime(&t));
				snprintf(path_mjpg, sizeof(path_mjpg), "%s-%s.mjpg",base,timestamp);
				snprintf(path_jpg, sizeof(path_jpg), "%s-%s.jpg", base, timestamp);
				snprintf(path_fps, sizeof(path_jpg), "%s-%s.fps", base, timestamp);
				record_in_file = 1;

				int fd = open(path_jpg, O_CREAT | O_TRUNC| O_WRONLY, S_IRWXU | S_IRWXG);
				write(fd, img, total_bytes);
				close(fd);
			
				if(diff>threshold)
				{
					char buf[128];
					snprintf(buf, sizeof(buf),
						"/bin/logevent notice odvision 'Motion in [%s]'", path_jpg);
					system(buf);
					syslog(LOG_NOTICE, "%s\n", buf);
				}

				fps_fd = open(path_fps, O_CREAT | O_APPEND | O_WRONLY, S_IRWXU | S_IRWXG);
				if(fps_fd<0)
					perror("open");

				recording_fd = open(path_mjpg, O_CREAT | O_APPEND | O_WRONLY, S_IRWXU | S_IRWXG);
				if(recording_fd<0)
					perror("open");

				char *http_str = 
		"Content-Type: multipart/x-mixed-replace; boundary=--odboundary\r\n";
				write(recording_fd, http_str, strlen(http_str));		
			}
		}

		// In recording by threshold, we stop recording when there are not
		// significant differences detected. We wait X seconds.
		//printf("diff: %d, threshold: %d, time(t): %d\n", diff, threshold, t);
		if(record_in_file && diff<=threshold && flags & M_RECORD_THRESHOLD)
		{
			// motion detected and recording after, X seconds it stops
			if(time(NULL)-t > WAIT_IF_NO_MOTION)
			{
				syslog(LOG_NOTICE, "stop recording: %d\n", time(NULL));
				// we stop recording
				record_in_file = 0;
				char str[16];
				char buf[256];
				float frames = 0;
				if(time(NULL)-frames_tm > 0)
					frames = (float)frames_cnt/(time(NULL)-frames_tm);
				snprintf(str, sizeof(str), "%f", frames);
				write(fps_fd, str, strlen(str));
				close(fps_fd);
				close(recording_fd);
				chmod(path_mjpg, 00777);
				chown(path_mjpg, 1000, 1000);
				chmod(path_jpg, 00777);
				chown(path_jpg, 1000, 1000);
				chmod(path_fps, 00777);
				chown(path_fps, 1000, 1000);
				snprintf(buf, sizeof(buf),
					"/bin/logevent filesave odvision 'Video recorded' %s", path_mjpg);
				system(buf);
				syslog(LOG_NOTICE, "%s\n", buf);
			}
		}
		else if(diff > threshold)
		{
			// reset timer
			t = time(NULL);
		}
		

		// write frame in file
		if(record_in_file==1)
		{
			r=write_frame(recording_fd, "", "--odboundary", ct, cl, img, len);
			goto_error_if_fail(r);
		}


		// write frame in standard output
		if(flags & M_STDOUT)
		{

			// TODO: improve total time
			float usec=0;
			if(fps>0)
				usec = 1000000 * (float)1/fps;
				
			usleep(usec);

			r=write_frame(1, "", boundary, ct, cl, img, len);
			goto_error_if_fail(r);

		}

		frames_cnt++;


		if((flags & M_READ_FROM_FILE) && (flags & M_OFFSET))
			if(p->offset_stop)
			{
				syslog(LOG_DEBUG, "stream stopped\n");
				break;
			}
	}


	close(fd);
	return 0;

error:
	if(stop)
		syslog(LOG_ERR, "Stop signal has been received\n");
	else
		syslog(LOG_ERR, "mjpg_streaming() end\n");

	close(fd);

	// save recording
	if(recording_fd>0)
	{
		syslog(LOG_ERR, "saving recording...\n");

		char str[16];
		float frames = 0;
		if(time(NULL)-frames_tm > 0)
			frames = (float)frames_cnt/(time(NULL)-frames_tm);

		snprintf(str, sizeof(str), "%f", frames);
		write(fps_fd, str, strlen(str));
		close(fps_fd);
		close(recording_fd);
		chmod(path_mjpg, 00777);
		chown(path_mjpg, 1000, 1000);
		chmod(path_jpg, 00777);
		chown(path_jpg, 1000, 1000);
		chmod(path_fps, 00777);
		chown(path_fps, 1000, 1000);
		snprintf(buf, sizeof(buf),
			"/bin/logevent filesave odvision 'Video recorded' %s", path_mjpg);
		system(buf);
		syslog(LOG_NOTICE, "%s\n", buf);
	}
	return -10;

}
// }}}

// {{{ mjpg_verify()
int mjpg_verify(const char *host, const char *url, size_t port, 
				const char *credentials)
{
	
	char line[128];
	int nbytes=0;
	int res = 0;
	
	int sockfd = socket_open(host, url, port, credentials);
	
	if (sockfd <= 0)
		return -1;
	
	/* find mjpeg strings for camera verification */
	while((nbytes = recvline(line, sizeof(line), sockfd))>=0)
	{
		if(strstr(line, "boundary=") || strstr(line, "--BoundaryString"))
		{
			//printf("GOOD:%s\n",line);
			res = 0;
			break;
		}
		else {
			res = -1;
			//printf("BAD:%s\n",line);
			
		}
		
	}
	
	if (nbytes < 0 || res != 0) {
		res = -1;
	}else {
		res = 0;
	}
	
	close(sockfd);
	return res;
}
int main(int argc, char** argv)
{
	if(argc > 3)
	{
		double t1, t2, t3;
		struct timeval t_s1, t_e1, t_s2, t_e2, t_s3, t_e3;

		image_height=atoi(argv[1]);
		image_width=atoi(argv[1]);
		if(atoi(argv[2]) == 1)
			create_image();

		image = (char*)malloc(sizeof(char)*image_height*image_width);
		meet=(ConsensusGrid*)malloc(sizeof(ConsensusGrid)*image_height*image_width);
		basis = (int*)malloc(sizeof(int)*image_height*image_width);

		read_raw_image("image.raw",image,image_height,image_width);

		cout << "Calculating consensus..." << endl << endl;
		for(int i=0; i<image_height; i++)
		{
			for(int j = 0; j<image_width; j++)
			{
				if(atoi(argv[3]) == 1)
				{
				        gettimeofday(&t_s1, NULL);

					meet[i*image_width+j]=consensus_parallel(i, j, image,image_height,image_width);

					gettimeofday(&t_e1, NULL);
        				t1 = (((double)t_e1.tv_sec-(double)t_s1.tv_sec)*1000) + ((double)t_e1.tv_usec - (double)t_s1.tv_usec)/1000;
				}
				else
				{
                                        gettimeofday(&t_s1, NULL);
					meet[i*image_width+j]=consensus(i, j, image,image_height,image_width);
                                        gettimeofday(&t_e1, NULL);
                                        t1 = (((double)t_e1.tv_sec-(double)t_s1.tv_sec)*1000) + ((double)t_e1.tv_usec - (double)t_s1.tv_usec)/1000;
				}
			}
		}

		cout << "Calculating list..." << endl << endl;
		if(atoi(argv[3]) == 1)
		{
        		gettimeofday(&t_s2, NULL);
			calculate_list_parallel();
			gettimeofday(&t_e2, NULL);
		        t2 = (((double)t_e2.tv_sec-(double)t_s2.tv_sec)*1000) + ((double)t_e2.tv_usec - (double)t_s2.tv_usec)/1000;

		}
		else
		{
                        gettimeofday(&t_s2, NULL);
			calculate_list();
                        gettimeofday(&t_e2, NULL);
                        t2 = (((double)t_e2.tv_sec-(double)t_s2.tv_sec)*1000) + ((double)t_e2.tv_usec - (double)t_s2.tv_usec)/1000;

		}
		cout << "Calculating basis..." << endl << endl;
		if(atoi(argv[3]) == 1)
		{
       		 	gettimeofday(&t_s3, NULL);
			calculate_basis();

			gettimeofday(&t_e3, NULL);
        		t3 = (((double)t_e3.tv_sec-(double)t_s3.tv_sec)*1000) + ((double)t_e3.tv_usec - (double)t_s3.tv_usec)/1000;
		}
		else
		{
                        gettimeofday(&t_s3, NULL);
			calculate_basis();
                        gettimeofday(&t_e3, NULL);
                        t3 = (((double)t_e3.tv_sec-(double)t_s3.tv_sec)*1000) + ((double)t_e3.tv_usec - (double)t_s3.tv_usec)/1000;

		}
		cout << "Basis count = " << basis_count << endl;

		cout << endl << "Time for Parallel Consensus Calculation = " << t1 << " msec" << endl;
		cout << "Time for Parallel List Calculation = " << t2 << " msec" << endl;
		cout << "Time for Basis  Calculation = " << t3 << " msec" << endl;
	}

	else
	{
		cout << "Insufficient arguments\n" << endl;
		cout << "First argument = Image Size" << endl;
		cout << "Second argument = 1 to create image, 0 not to create image" << endl;
		cout << "Third argument = 1 for parallel, 0 for not parallel\n" << endl;
	}
}
int main(int argc, char** argv)
{
	if(argc > 1)
	{
		int* basis_serial;
		int* basis_parallel;
		int basis_count1, basis_count2;

		image_height=atoi(argv[1]);
		image_width=atoi(argv[1]);
		

		create_image();

		image = (char*)malloc(sizeof(char)*image_height*image_width);
		meet=(ConsensusGrid*)malloc(sizeof(ConsensusGrid)*image_height*image_width);
		basis = (int*)malloc(sizeof(int)*image_height*image_width);

		read_raw_image("image.raw",image,image_height,image_width);

		struct timeval t_s, t_e;
        	gettimeofday(&t_s, NULL);
		/// For serial implementation
		for(int i=0; i<image_height; i++)
		{
			for(int j = 0; j<image_width; j++)
			{
				meet[i*image_width+j]=consensus(i, j, image,image_height,image_width);
			}
		}

		printf("Calculating list for serial\n");
		calculate_list();

		printf("Calculating basis for serial\n");
		calculate_basis();
		gettimeofday(&t_e, NULL);

        	double t1 = (((double)t_e.tv_sec-(double)t_s.tv_sec)*1000) + ((double)t_e.tv_usec - (double)t_s.tv_usec)/1000;

		basis_serial = basis;

		basis_count1 = basis_count;
		cout << "Serial Basis count = " << basis_count << endl << endl;;

		reset_values();
		
		/// For parallel implementation
		struct timeval t_s2, t_e2;
	        gettimeofday(&t_s2, NULL);

                for(int i=0; i<image_height; i++)
                {
                        for(int j = 0; j<image_width; j++)
                        {
                                meet[i*image_width+j]=consensus_parallel(i, j, image,image_height,image_width);
                        }
                }

                printf("Calculating list for parallel\n");
                calculate_list();

                printf("Calculating basis for parallel\n");
		calculate_basis();
		gettimeofday(&t_e2, NULL);
       		double t2 = (((double)t_e2.tv_sec-(double)t_s2.tv_sec)*1000) + ((double)t_e2.tv_usec - (double)t_s2.tv_usec)/1000;

                basis_parallel = basis;

		basis_count2 = basis_count;
                cout << "Parallel Basis count = " << basis_count << endl << endl;

		Assert_Output(basis_serial, basis_parallel, basis_count1, basis_count2);

	}

	else
	{
		cout << "Insufficient arguments\n" << endl;
		cout << "First argument = Image Size" << endl;
	}
}