def __init__(self):
     self.root = Tk()
     self.picture = ImageProcessing()
     self.option = StringVar()
     self.option.set("Default")
     self.actions = OptionMenu(self.root, self.option, "Default", "Edge",
                               "Grayscale", "Red Hue", "Green Hue",
                               "Blue Hue", "Change the Saturation",
                               "White Hue", "Invert Colors",
                               "To French Flag", "Customise")
     self.option.trace('w', self.optionChange)
     self.actions.grid(row=0, column=0)
     self.newPictureButton = Button(self.root,
                                    text="New Picture",
                                    command=self.changePicture)
     self.newPictureButton.grid(row=0, column=1)
     try:
         self.p = self.picture.getImage()
         self.photo = ImageTk.PhotoImage(self.p)
         self.hValue = Spinbox()
         self.sValue = Spinbox()
         self.vValue = Spinbox()
         self.imageLabel = Label(self.root, image=self.photo)
         self.imageLabel.grid(row=1, column=0, columnspan=15)
         self.root.mainloop()
     except:
         self.root.destroy()
Exemple #2
0
    def __init__(self):
        self.Camera = IC.TIS_CAM()
        #self.Camera.ShowDeviceSelectionDialog()
        print("Open Camera:         ",
              self.Camera.openVideoCaptureDevice(
                  "DMK 33UX174"))  # Hier richtige Kamera einfügen!!
        print("VideoFormat:         ",
              self.Camera.SetVideoFormat("Y800 (1920x1200)")
              )  # Format der Kamera auf Y16 setzen mit richtiger Auflösung!!
        self.Camera.SetFormat(IC.SinkFormats.Y800)  # No Return Value
        print("Continuous Mode OFF: ", self.Camera.SetContinuousMode(0))
        self.Camera.StartLive(0)
        print("Gain Auto off:       ",
              self.Camera.SetPropertySwitch("Gain", "Auto",
                                            0))  # Gain Manuell einstellen
        print("Gain Value set:      ",
              self.Camera.SetPropertyValue("Gain", "Value", 280))  # Gain auf 0
        print("Brightness Value Set:",
              self.Camera.SetPropertyValue(
                  "Brightness", "Value",
                  240))  # Brightness auch auf 0 (=BlackLevel)
        print("Exposure Auto off:   ",
              self.Camera.SetPropertySwitch("Exposure", "Auto", 0))
        print("Exposure Value set:  ",
              self.Camera.SetPropertyAbsoluteValue(
                  "Exposure", "Value", 0.01))  #Exposure time in seconds

        self.maxIntensity = 65536
        self.minIntensity = 0

        # Für Callback:
        self.ImProc = ImageProcessing()
        self.Callbackfunc = IC.TIS_GrabberDLL.FRAMEREADYCALLBACK(self.Callback)
        self.ImageDescription = CallbackUserdata()
        print(
            "set Callback        :",
            self.Camera.SetFrameReadyCallback(self.Callbackfunc,
                                              self.ImageDescription))
        self.Imageformat = self.Camera.GetImageDescription()[:3]
        self.ImageDescription.width = self.Imageformat[0]
        self.ImageDescription.height = self.Imageformat[1]
        self.ImageDescription.iBitsPerPixel = self.Imageformat[2] // 8
        self.ImageDescription.buffer_size = self.ImageDescription.width * self.ImageDescription.height * self.ImageDescription.iBitsPerPixel
        print("ImageDescription height:", self.ImageDescription.height)
        print("ImageDescription width :", self.ImageDescription.width)
        print("ImageDescription BpP   :", self.ImageDescription.iBitsPerPixel)
        self.Camera.StopLive()
Exemple #3
0
 def __init__(self):
     image = ImageProcessing(filename='nico-sleep.jpg', dither=1)
Exemple #4
0
def main():
    rover = ImageProcessing()
    rover.execute()
Exemple #5
0

sentOnNotes = []

minFrequency = 500
maxFrequency = 7000
duration = 30

timePerLoop = 200
loopsPerImageProcessing = 5

imageHeight = 400

originalImage = cv2.imread("test4.jpg")
originalSize = originalImage.shape[:2]
ip = ImageProcessing()

loopsSinceImageProcessed = loopsPerImageProcessing

print("MIDI output ports: ", mido.get_output_names())

outputName = mido.get_output_names()[0]
midiOutput = mido.open_output("LoopBe Internal MIDI 1")

#exit()

resizedImage = cv2.resize(
    originalImage,
    (round(imageHeight / originalSize[0] * originalSize[1]), imageHeight))
ip.processImage(resizedImage)
class VideoProcessing:
    def __init__(self, videoName):
        self.videoName = videoName
        self.frameCounter = 0
        self.second = 0

    def videoFunction(self):
        cap = cv2.VideoCapture(self.videoName)
        first = time.time()
        while (cap.isOpened()):
            _, frame = cap.read()
            if frame is not None:
                imageProcessing.image = frame
                cv2.imshow(self.videoName, imageProcessing.imageFunction())
                last = time.time() - first
                if 0.95 < last < 1.01:
                    self.second += 1
                    print(self.second, "second(s),", "FPS:", self.frameCounter)
                    self.frameCounter = 0
                    first = time.time()
                self.frameCounter = self.frameCounter + 1
                if cv2.waitKey(1) & 0xFF == ord('q'):
                    break
            else:
                print("The video is finished.")
                cap.release()
                cv2.destroyAllWindows()


imageProcessing = ImageProcessing()
Exemple #7
0
                print("Choose Camera!!!")

app = QApplication(sys.argv)
win = GUI(100, 100, 900, 225, "Autonomous Car")
win.show()
sys.exit(app.exec_())
"""
while (True):
    print(
        "What do you want to do? (Image & Video Processing: 1, Simulation Processing: 2, Driving: 3, Exit: 0)"
    )
    decision = int(input())
    if decision == 1:
        imageName = "RoadPhotoWithSign.png"
        videoName = "RoadVideo_Trim1.mp4"
        imageProcessing = ImageProcessing(imageName)
        imageProcessing.displayingScreen(imageName,
                                         imageProcessing.imageFunction())
        videoProcessing = VideoProcessing(videoName)
        videoProcessing.videoFunction()
    elif decision == 2:
        print(
            "Which camera do you use in the simulation (Main Camera:1, Side Camera: 2, Exit:0)"
        )
        camera = int(input())
        if camera == 1:
            simulationProcessing = SimulationProcessing("MainCamera")
        elif camera == 2:
            simulationProcessing = SimulationProcessing("SideCamera")
        elif camera == 0:
            break
Exemple #8
0
from hcsr04 import DistSensor
from carControl import CarControl
from imageProcessing import ImageProcessing
from os import system
import traceback

learningMode = True  #This variable should come from the Android Application.

dsThread = DistSensor(15, 100, 16, 18)
imThread = ImageProcessing(10, 640, 480, learningMode)
vehControl = CarControl(1, 0x04)

dsThread.start()
imThread.start()

try:
    while True:
        if learningMode == False:
            ftti = dsThread.getFilteredTimeToImpact()
            avgDist = dsThread.getAvgDistance()
            vehControl.updateThrottle(60)
            averageDirAngle = imThread.getAverageAngle()
            #max physical angle is about 25 degrees,
            #which means we should map -25 to 0 as 1-50 and 1-25 as 51 - 100
            if averageDirAngle is not None:
                if averageDirAngle < -25:
                    averageDirAngle = -25
                elif averageDirAngle > 25:
                    averageDirAngle = 25

                vehControl.updateDirection(50 + (averageDirAngle * 2))