| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | { |
| | | try |
| | | { |
| | | System.out.println(getName() + " - 1.RUN"); |
| | | if (Shared.isServerEnabled() == true) |
| | | { |
| | | System.out.println(getName() + " - 2.RUN"); |
| | | update(); |
| | | System.out.println(getName() + " - 3.RUN"); |
| | | } |
| | | } |
| | | catch (Exception exception) |
| | | { |
| | | // exception.printStackTrace(); |
| | | exception.printStackTrace(); |
| | | } |
| | | |
| | | try |
| | |
| | | private void update() throws Exception |
| | | { |
| | | while (readDetections() == true); |
| | | { |
| | | try{sleep(100);} catch (Exception e){}; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | if (detectionsCameraLane.size() > 0) detectionsCamera.addAll(detectionsCameraLane); |
| | | } |
| | | |
| | | // Shared.println(this.getName(), "1.ReadDetections: " + detectionsCamera.size()); |
| | | for (AccessEnforcement_Detection detection : detectionsCamera) |
| | | { |
| | | lastDetectionTimestamp = Math.max(lastDetectionTimestamp, detection.timestamp); |
| | |
| | | } |
| | | |
| | | this.lastDetection = lastDetectionTimestamp; |
| | | // Shared.println(this.getName(), "2.ReadDetections: " + detectionsCamera.size() + " - " + new Date(this.lastDetection).toString()); |
| | | |
| | | |
| | | // Insert into database and update timestamps |
| | |
| | | { |
| | | try |
| | | { |
| | | // Shared.println(this.getName(), "3.ReadDetections Detection: " + detection); |
| | | // Shared.println(this.getName(), "4.ReadDetections Detection: " + detection.images); |
| | | // Shared.println(this.getName(), "5.ReadDetections Detection: " + detection.getLastState()); |
| | | // Shared.println(this.getName(), "5.ReadDetections Detection: " + detection.getLastState().vehicle); |
| | | if ((detection.images == null) || (detection.images.size() == 0)) |
| | | { |
| | | getImagesDetectionUC(access, detection); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Shared.printstack(this.getName(), e); |
| | | Shared.printstack(this.getName(), e); |
| | | } |
| | | |
| | | |
| | | AccessEnforcement_Detection_State detectionState = detection.getLastState(); |
| | | |
| | | if (detectionState == null) detectionState = new AccessEnforcement_Detection_State(); |
| | | |
| | | if ((detection.images != null) && (detection.images.size() >= 2)) |
| | | { |
| | | if (Shared.controllerDetections.hasPermission(detection, detectionState.vehicle.plate) != null) |
| | |
| | | detectionState.discarded.code = AccessEnforcement_Detection_State_Discarded.DISCARDED_ALLOWED; |
| | | detectionState.discarded.timestamp = System.currentTimeMillis(); |
| | | detectionState.discarded.user = Shared.getApplicationName(); |
| | | // Shared.printcorrect(getName(),Shared.getMessage("Successful (allowed), plate") + " = " + detectionState.vehicle.plate + ", " + Shared.getMessage("date") + " = " + formato2.format(detection.timestamp)); |
| | | Shared.printcorrect(getName(),Shared.getMessage("Successful (allowed), plate") + " = " + detectionState.vehicle.plate + ", " + Shared.getMessage("date") + " = " + formato2.format(detection.timestamp)); |
| | | } |
| | | else if ((this.detail.detections != null) && (detectionState.vehicle.confidence.floatValue() < this.detail.detections.plateConfidence) && |
| | | (this.detail.detections.enabled == true)) |
| | |
| | | detectionState.discarded.code = AccessEnforcement_Detection_State_Discarded.DISCARDED_LOW_OCR_CONFIDENCE; |
| | | detectionState.discarded.timestamp = System.currentTimeMillis(); |
| | | detectionState.discarded.user = Shared.getApplicationName(); |
| | | // Shared.printerr(getName(),Shared.getMessage("Low ocr confidence, plate") + " = " + detectionState.vehicle.plate + ", " + Shared.getMessage("confidence") + " = " + detectionState.vehicle.confidence.floatValue() + ", " + Shared.getMessage("date") + " = " + formato2.format(detection.timestamp)); |
| | | Shared.printerr(getName(),Shared.getMessage("Low ocr confidence, plate") + " = " + detectionState.vehicle.plate + ", " + Shared.getMessage("confidence") + " = " + detectionState.vehicle.confidence.floatValue() + ", " + Shared.getMessage("date") + " = " + formato2.format(detection.timestamp)); |
| | | } |
| | | else |
| | | { |
| | | detectionState.state = AccessEnforcement_Detection_State.STATE_REVISION_PENDING; |
| | | detectionState.timestamp = System.currentTimeMillis(); |
| | | // Shared.printcorrect(getName(),Shared.getMessage("Successful (revision pending), plate") + " = " + detectionState.vehicle.plate + ", " + Shared.getMessage("date") + " = " + formato2.format(detection.timestamp)); |
| | | Shared.printcorrect(getName(),Shared.getMessage("Successful (revision pending), plate") + " = " + detectionState.vehicle.plate + ", " + Shared.getMessage("date") + " = " + formato2.format(detection.timestamp)); |
| | | } |
| | | } |
| | | else |
| | |
| | | detectionState.discarded.code = AccessEnforcement_Detection_State_Discarded.DISCARDED_MISSING_PICTURES; |
| | | detectionState.discarded.timestamp = System.currentTimeMillis(); |
| | | detectionState.discarded.description = detectionState.discarded.getDescription(detectionState.discarded.code); |
| | | // Shared.printerr(getName(),Shared.getMessage("Missing images, plate") + " = " + detectionState.vehicle.plate + ", " + Shared.getMessage("date") + " = " + formato2.format(detection.timestamp)); |
| | | Shared.printerr(getName(),Shared.getMessage("Missing images, plate") + " = " + detectionState.vehicle.plate + ", " + Shared.getMessage("date") + " = " + formato2.format(detection.timestamp)); |
| | | } |
| | | |
| | | this.controller.updateDatabaseDetection(information, detection); |
| | |
| | | } |
| | | catch (Exception exception) |
| | | { |
| | | // Shared.printstack(getName(), exception); |
| | | Shared.printstack(getName(), exception); |
| | | } |
| | | |
| | | return false; |
| | |
| | | SimpleDateFormat formato1 = new SimpleDateFormat("dd/MM/yyyy"); |
| | | SimpleDateFormat formato2 = new SimpleDateFormat("HH:mm:ss"); |
| | | |
| | | String url = "https://" + information.neural.connection.address + ":" + information.neural.connection.port + "/art?operation=getDetections"; |
| | | String url = "https://" + information.neural.connection.address + "/art?operation=getDetections"; |
| | | url += "&from=" + formato1.format(from) + "%20" + formato2.format(from); |
| | | url += "&to=" + formato1.format(to) + "%20" + formato2.format(to); |
| | | url += "&lane=" + lane; |
| | |
| | | |
| | | url += "&token=" + user + "," + password; |
| | | |
| | | // Shared.println(this.getName(), "1.URL GetDEtections: " + url); |
| | | Shared.println(this.getName(), "URL: " + url); |
| | | byte[] response = HttpsRequest.requestBytes(url, user, password, new byte[0], 30000, 60000); |
| | | AccessEnforcement_Detection[] ucDetections = Serialization.deserialize(AccessEnforcement_Detection[].class, response); |
| | | // Shared.println(this.getName(), "2.GetDEtections: " + ucDetections.length); |
| | | |
| | | for (AccessEnforcement_Detection ucDetection : ucDetections) |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Shared.printstack(this.getName(), e); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Shared.printstack(this.getName(), e); |
| | | Shared.printstack(this.getName(), e); |
| | | } |
| | | |
| | | return detections; |
| | |
| | | // https://10.106.7.18/art?operation=getImage&incidence=22758&name=overview&token=write,EdubVmde |
| | | // https://10.106.7.18/art?operation=getImage&incidence=22758&name=plate&token=write,EdubVmde |
| | | |
| | | String urlOverview = "https://" + access.getDeviceInformation().neural.connection.address + ":" + access.getDeviceInformation().neural.connection.port + "/art?operation=getImage"; |
| | | String urlOverview = "https://" + access.getDeviceInformation().neural.connection.address + "/art?operation=getImage"; |
| | | urlOverview += "&incidence=" + detection.incidence; |
| | | urlOverview += "&name=overview"; |
| | | |
| | |
| | | } |
| | | |
| | | urlOverview += "&token=" + user + "," + password; |
| | | // Shared.println(this.getName(), "1.GetImages URLOver: " + urlOverview); |
| | | byte[] response = HttpsRequest.requestBytes(urlOverview, user, password, new byte[0], 30000, 60000); |
| | | // Shared.println(this.getName(), "2.GetImages URLOver: " + urlOverview); |
| | | |
| | | AccessEnforcement_Detection_Image imageOverview = new AccessEnforcement_Detection_Image(); |
| | | imageOverview.format = "jpg"; |
| | |
| | | imageOverview.data = response; |
| | | accessDetectionImages.add(imageOverview); |
| | | |
| | | String urlPlate = "https://" + access.getDeviceInformation().neural.connection.address + ":" + access.getDeviceInformation().neural.connection.port + "/art?operation=getImage"; |
| | | String urlPlate = "https://" + access.getDeviceInformation().neural.connection.address + "/art?operation=getImage"; |
| | | urlPlate += "&incidence=" + detection.incidence; |
| | | urlPlate += "&name=plate"; |
| | | urlPlate += "&token=" + user + "," + password; |
| | |
| | | } |
| | | catch (SerializationException e) |
| | | { |
| | | // Shared.printstack(this.getName(), e); |
| | | if (e.getMessage().indexOf("NoSuchFileException") < 0) |
| | | { |
| | | throw e; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Shared.printstack(this.getName(), e); |
| | | throw e; |
| | | } |
| | | |
| | |
| | | { |
| | | public void run() |
| | | { |
| | | // Shared.println(getName(), Shared.getMessage("Total detections in last minute") + " = " + counterDetections); |
| | | Shared.println(getName(), Shared.getMessage("Total detections in last minute") + " = " + counterDetections); |
| | | counterDetections = 0; |
| | | } |
| | | }, delay, 60000, TimeUnit.MILLISECONDS); |