Nå tar den bilde med termux.
This commit is contained in:
		
							parent
							
								
									6055f7f4ee
								
							
						
					
					
						commit
						1cb602f024
					
				
							
								
								
									
										
											BIN
										
									
								
								camera/__pycache__/config.cpython-310.pyc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								camera/__pycache__/config.cpython-310.pyc
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										3
									
								
								camera/config.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								camera/config.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | config = { | ||||||
|  |         'uploadurl': 'http://10.10.40.2:5000/post_img' | ||||||
|  | } | ||||||
| @ -1,10 +1,29 @@ | |||||||
| from flask import Flask, request, jsonify | from flask import Flask, request, jsonify | ||||||
| import requests | import requests | ||||||
|  | import subprocess | ||||||
|  | import time | ||||||
|  | import logging | ||||||
| 
 | 
 | ||||||
| url = 'http://10.10.40.2:5000/post_img' | import config | ||||||
| my_img = {'image': open('test.png', 'rb')} | logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) | ||||||
| r = requests.post(url, files=my_img) |  | ||||||
| 
 | 
 | ||||||
| # convert server response into JSON format. | try: | ||||||
| print(r.json()) |   start = time.time() | ||||||
|  |   picturecmd=subprocess.Popen("termux-camera-photo -c 0 latest.jpg", shell=True) | ||||||
|  |   picturecmd.communicate() | ||||||
|  |   end = time.time()  | ||||||
|  | except Exception as e: | ||||||
|  |   logging.info('Feil under fotografering: {0}'.format(e)) | ||||||
|  | else: | ||||||
|  |   logging.info('Det tok '+ str(end-start) +'s å ta bilde.') | ||||||
| 
 | 
 | ||||||
|  | try: | ||||||
|  |   start = time.time() | ||||||
|  |   img = {'image': open('latest.jpg', 'rb')} | ||||||
|  |   response = requests.post(config.config['uploadurl'], files=img) | ||||||
|  |   end = time.time()  | ||||||
|  | except Exception as e: | ||||||
|  |     logging.info('Feil under opplasting: {0}'.format(e)) | ||||||
|  | else: | ||||||
|  |   print(response.json()) | ||||||
|  |   logging.info('Det tok '+ str(end-start) +'s å sende bildet.') | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user