pageauc / speed-camera

A Unix, Windows, Raspberry Pi Object Speed Camera using python, opencv, video streaming, motion tracking. Includes a Standalone Web Server Interface, Image Search using opencv template match and a whiptail Admin Menu Interface Includes picam and webcam Plugins for motion track security camera configuration including rclone sync script. watch-app allows remotely controller camera configuration from a remote storage service name. Uses sqlite3 and gnuplot for reporting. Recently added openalpr license plate reader support.
Apache License 2.0
983 stars 172 forks source link

get GUI working #23

Closed vdc4j95 closed 6 years ago

vdc4j95 commented 6 years ago

I am having some issues getting the GUI working on my Raspi2.

Settings -------------------------------------

Plugins ......... pluginEnable=False pluginName=picam480 Message Display . verbose=True display_fps=False calibrate=True show_out_range=True Logging ......... Log_data_to_CSV=True log_filename=speed-cam.csv (CSV format) loggingToFile=True logFilePath=speed-cam.log Log if max_speed_over > 1 mph Speed Trigger ... If track_len_trig > 75 px Exclude Events .. If x_diff_min < 1 or x_diff_max > 15 px If y_upper < 140 or y_lower > 340 px or x_left < 150 or x_right > 490 px If max_speed_over < 1 mph If event_timeout > 0 seconds Start New Track track_timeout=0 sec wait after Track Ends (avoid retrack of same object) Speed Photo ..... Size=960x720 px image_bigger=1 rotation=180 VFlip=True HFlip=True image_path=media/images image_Prefix=speed- image_font_size=22 px high image_text_bottom=False Motion Settings . Size=640x480 px px_to_kph=0.086600 speed_units=mph OpenCV Settings . MIN_AREA=200 sq-px BLUR_SIZE=10 THRESHOLD_SENSITIVITY=20 CIRCLE_SIZE=4 px WINDOW_BIGGER=1 gui_window_on=True (Display OpenCV Status Windows on GUI Desktop) CAMERA_FRAMERATE=25 fps video stream speed Sub-Directories . imageSubDirMaxHours=0 (0=off) imageSubDirMaxFiles=1000 (0=off) imageRecentDir=media/recent imageRecentMax=100 (0=off) Disk Space ..... Enabled - Manage Target Free Disk Space. Delete Oldest jpg Files if Needed Check Every spaceTimerHrs=24 hr(s) (0=off) Target spaceFreeMB=500 MB min is 100 MB) If Needed Delete Oldest spaceFileExt=jpg spaceMediaDir=media/images


(Movement (q Quits):1481): Gtk-WARNING **: cannot open display:

pageauc commented 6 years ago

gui_window_on=True should show the opencv windows cv2.imshow(). There are also variables for show_thresh_on, show_crop_on plus the default full image2 window. You may need to add your own cv2.imshow() to display what you want. Your problem may be how you put in the new logic since you may not have the window name variable and image to display set correctly. Check logic and make sure the variables are correct. The speed-cam.py code to display windows is below. It is located just above if name == 'main': near end of code. Make sure variables for the image you want to show are compatible with the new code you added. You can always add some debug code to help find out where the problem is.

    if gui_window_on:
        # cv2.imshow('Difference Image',difference image)
        cv2.line(image2, (x_left, y_upper), (x_right, y_upper), cvRed, 1)
        cv2.line(image2, (x_left, y_lower), (x_right, y_lower), cvRed, 1)
        cv2.line(image2, (x_left, y_upper), (x_left, y_lower), cvRed, 1)
        cv2.line(image2, (x_right, y_upper), (x_right, y_lower), cvRed, 1)
        image_view = cv2.resize(image2, (image_width, image_height))
        cv2.imshow('Movement (q Quits)', image_view)
        if show_thresh_on:
            cv2.imshow('Threshold', thresholdimage)
        if show_crop_on:
            cv2.imshow('Crop Area', image_crop)
        # Close Window if q pressed
        if cv2.waitKey(1) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            logging.info("End Motion Tracking ......")
            vs.stop()
            still_scanning = False