当我第一次单击模式打开按钮时,它会在方法中使count = 1递增,并在我单击计数增量的项目中的任何位置每次打印该值。 然后关闭模态后,我在搜索屏幕上单击,该方法也使count变量的值增加3,然后当我单击模态按钮时,count值增加,但显示旧值。我尝试了oninit()和onChanges,但仍然是相同的问题
constructor(private router: Router, private chassieSpecService: ChassieSpecService, private userIdle: UserIdleService, private auth: AuthenticationService) {}
ngOnInit() {
this.getRecentAddedChassis();
}
getRecentAddedChassis(): void {
this.count++;
alert("recet added " + this.count);
// working code
this.chassieSpecService.getRecentAddedChassis().subscribe(data => {
// console.log("recentAddedChassis "+data) ;
alert(this.recentAddedChassis); //showing updated values everytime
this.recentAddedChassis = data;
this.router.navigate(['chassisSpec']);
});
}
导出类ChassieSpecComponent实现OnInit,OnChanges {
import cv2
import numpy as np
lower = np.array([163, 84, 93],np.uint8)
upper = np.array([187, 237, 255],np.uint8)
x1 = 51
x2=586
y1=111
y2=381
w=50
cam_capture = cv2.VideoCapture(0)
cv2.destroyAllWindows()
Top_left = (x1+1, y1-1-w)
Top_right = (x2+1, y1-1)
top_pixles=abs((y1-1-y1-1-w)*(x2+1-x1+1))
while True:
_, image_frame = cam_capture.read()
# Top Rectangle marker
top = cv2.rectangle(image_frame, Top_left, Top_right, (100, 50, 200), 5)
rect_top = image_frame[Top_left[1]: Top_right[1], Top_left[0]:Top_right[0]]
# top red
hsv_top = cv2.cvtColor(rect_top, cv2.COLOR_BGR2HSV)
top_red = cv2.inRange(hsv_top, lower, upper)
top_red_pixle = cv2.countNonZero(top_red)
print("\t"+str(int(top_red_pixle/top_pixles*100)))
cv2.imshow("Sketcher ROI", image_frame)
key = cv2.waitKey(1) & 0xFF
if key == 27:
break
cv2.destroyAllWindows()
}``