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()
Example #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()
 def gettingImage(self, img):
     greenLowerColor = np.array([40, 40, 40])
     greenUpperColor = np.array([70, 255, 255])
     redLowerColor = np.array([110, 50, 50])
     redUpperColor = np.array([130, 255, 255])
     maskedGreenImage = ImageProcessing.colorDetection(
         self, img, greenLowerColor, greenUpperColor)
     maskedRedImage = ImageProcessing.colorDetection(
         self, img, redLowerColor, redUpperColor)
     ImageProcessing.showingScreen(self, "Sensor", np.array(img))
     ImageProcessing.showingScreen(self, "Green", maskedGreenImage)
     ImageProcessing.showingScreen(self, "Red", maskedRedImage)
     return maskedGreenImage, maskedRedImage
Example #4
0
 def __init__(self):
     image = ImageProcessing(filename='nico-sleep.jpg', dither=1)
Example #5
0
def main():
    rover = ImageProcessing()
    rover.execute()
Example #6
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()
        file.close()


def move_log():
    try:
        shutil.copyfile(
            "log.txt", "logs/log_" +
            str(datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S:%f')) +
            ".txt")
        os.remove("log.txt")
    except:
        log("Error: " + str(sys.exc_info()))
        print("Error: " + str(sys.exc_info()))


imgProcessing = ImageProcessing()
verificaPlaca = vp()
move_log()

while (True):
    ret, frame = cap.read()
    if ret == True:
        log("New frame captured at " +
            datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S:%f'))

        gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)

        img = Frame(np.array(Image.fromarray(gray)), str(image_name()), None,
                    None)
        cv.imwrite("../processed/original/" + img._id + ".png", img.image)
        log("Start processing frame " + str(img._id) + " at " +
Example #9
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
class Window():
    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()

    def optionChange(self, *args):
        """
        This method is called when the user changes options
        :param args:
        :return:none
        """

        self.imageLabel.grid_forget()
        img = self.picture.getImage()
        if self.option.get() == "Default":
            try:
                self.contrast.grid_forget()
            except:
                pass

            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass
            self.p = img
            self.photo = ImageTk.PhotoImage(self.p)
        elif self.option.get() == "Edge":
            try:
                self.contrast.grid_forget()
            except:
                pass

            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass
            self.p = self.picture.edge(img)
            self.photo = ImageTk.PhotoImage(self.p)
        elif self.option.get() == "Grayscale":
            try:
                self.contrast.grid_forget()
            except:
                pass

            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass
            self.p = self.picture.toGrayscale(img)
            self.photo = ImageTk.PhotoImage(self.p)
        elif self.option.get() == "Red Hue":
            try:
                self.contrast.grid_forget()
            except:
                pass

            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass
            self.p = self.picture.toRed(img)
            self.photo = ImageTk.PhotoImage(self.p)
        elif self.option.get() == "Green Hue":
            try:
                self.contrast.grid_forget()
            except:
                pass

            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass
            self.p = self.picture.toGreen(img)
            self.photo = ImageTk.PhotoImage(self.p)
        elif self.option.get() == "Blue Hue":
            try:
                self.contrast.grid_forget()
            except:
                pass

            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass
            self.p = self.picture.toBlue(img)
            self.photo = ImageTk.PhotoImage(self.p)
        elif self.option.get() == "Change the Saturation":
            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass

            self.contrast = Spinbox(self.root,
                                    from_=0.0,
                                    to_=2.0,
                                    increment=.1,
                                    command=self.updateSaturation)
            self.contrast.grid(row=0, column=2)
            self.updateSaturation()
        elif self.option.get() == "White Hue":
            try:
                self.contrast.grid_forget()
            except:
                pass

            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass
            self.p = self.picture.toWhite(img)
            self.photo = ImageTk.PhotoImage(self.p)
        elif self.option.get() == "Invert Colors":
            try:
                self.contrast.grid_forget()
            except:
                pass
            self.p = self.picture.invertColors(img)
            self.photo = ImageTk.PhotoImage(self.p)
        elif self.option.get() == "To French Flag":
            try:
                self.contrast.grid_forget()
            except:
                pass

            try:
                self.hLabel.grid_forget()
                self.hValue.grid_forget()
                self.sLabel.grid_forget()
                self.sValue.grid_forget()
                self.vLabel.grid_forget()
                self.vValue.grid_forget()
            except:
                pass
            self.p = self.picture.toFrenchFlag(img)
            self.photo = ImageTk.PhotoImage(self.p)
        else:
            try:
                self.contrast.grid_forget()
            except:
                pass

            self.hLabel = Label(self.root, text="Hue:")
            self.hLabel.grid(row=0, column=2)
            self.hValue = Spinbox(from_=1.0,
                                  to_=4.0,
                                  increment=.2,
                                  command=self.updateHSV)
            self.hValue.grid(row=0, column=3)

            self.sLabel = Label(self.root, text="Saturation: ")
            self.sLabel.grid(row=0, column=4)
            self.sValue = Spinbox(from_=1.0,
                                  to_=4.0,
                                  increment=.2,
                                  command=self.updateHSV)
            self.sValue.grid(row=0, column=5)

            self.vLabel = Label(self.root, text="Value: ")
            self.vLabel.grid(row=0, column=6)
            self.vValue = Spinbox(from_=1.0,
                                  to_=4.0,
                                  increment=.2,
                                  command=self.updateHSV)
            self.vValue.grid(row=0, column=7)

            self.updateHSV()

        self.imageLabel = Label(self.root, image=self.photo)
        self.imageLabel.grid(row=1, column=0, columnspan=15)

    def updateSaturation(self):
        """
        This is for updating the saturation of the image with the imageProcessing.changeSaturation() method
        :return:
        """
        self.p = self.picture.changeSaturation(self.picture.getImage(),
                                               self.contrast.get())
        self.photo = ImageTk.PhotoImage(self.p)
        self.imageLabel = Label(self.root, image=self.photo)
        self.imageLabel.grid(row=1, column=0, columnspan=15)

    def updateHSV(self):
        """
        This updates the image through the imageProcessing.toCustomHSV() method
        :return:
        """
        self.p = self.picture.toCustomHSV(self.picture.getImage(),
                                          self.hValue.get(), self.sValue.get(),
                                          self.vValue.get())
        self.photo = ImageTk.PhotoImage(self.p)
        self.imageLabel = Label(self.root, image=self.photo)
        self.imageLabel.grid(row=1, column=0, columnspan=15)

    def changePicture(self):
        self.picture.setImage(self.picture.prompt_and_set_file())
        self.imageLabel.grid_forget()
        img = self.picture.getImage()
        self.p = img
        self.photo = ImageTk.PhotoImage(self.p)
        self.imageLabel = Label(self.root, image=self.photo)
        self.imageLabel.grid(row=1, column=0, columnspan=15)
Example #11
0
class ISCamera():
    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()

    def triggerSettings(self):
        self.ImProc.setTriggerMode(1)
        self.Camera.StartLive(0)
        print("Trigger Mode ON:     ",
              self.Camera.SetPropertySwitch("Trigger", "Enable", 1))
        print("Trigger rising Edge: ",
              self.Camera.SetPropertySwitch("Trigger", "Polarity", 1))
        print("Trigger Debounce Set:",
              self.Camera.SetPropertyAbsoluteValue("Trigger", "Debounce Time",
                                                   1000))  #1ms debounce time

    def startLiveMode(self):
        self.ImProc.setTriggerMode(0)
        #print("Trigger Mode OFF:     ",self.Camera.SetPropertySwitch("Trigger","Enable",0))
        #self.Camera.SetFrameRate(30.0)
        print("Trigger Mode ON:     ",
              self.Camera.SetPropertySwitch("Trigger", "Enable", 1))
        print("Trigger rising Edge: ",
              self.Camera.SetPropertySwitch("Trigger", "Polarity", 1))
        print("Trigger Debounce Set:",
              self.Camera.SetPropertyAbsoluteValue("Trigger", "Debounce Time",
                                                   1000))  #1ms debounce time
        self.Camera.StartLive(
            0
        )  #1: Video wird gezeigt, 0: Video wird nicht gezeigt (gestartet wird dennoch)

    def snapImg(self):
        self.Camera.SnapImage()
        return self.Camera.GetImage()

    def stopLive(self):
        self.Camera.StopLive()

    def getImage(self):
        return self.Camera.GetImage()

    def setGain(self, value):
        print("Gain Value set:      ",
              self.Camera.SetPropertyValue("Gain", "Value",
                                           value))  # Gain auf übergebenen Wert

    def setBrightness(self, value):
        print("Brightness Value Set:",
              self.Camera.SetPropertyValue("Brightness", "Value", value))

    def printParams(
        self
    ):  #Zum Debuggen: Zeigt, ob Parameter von der Kamera übernommen wurden oder nicht
        GainValue = [0]
        error = self.Camera.GetPropertyAbsoluteValue("Gain", "Value",
                                                     GainValue)
        if error == 1:
            print("Gain Value:      ", GainValue[0])
        else:
            print("Gain Error:      ", error)
        BrightnessValue = [0]
        ExposureTime = [0]
        error = self.Camera.GetPropertyAbsoluteValue("Exposure", "Value",
                                                     ExposureTime)
        if error == 1:
            print("Exposure Value:  ", ExposureTime[0])
        else:
            print("Exposure Error:  ", error)

    def getImprocPictures(self):
        picture1 = self.ImProc.getImage_01
        picture2 = self.ImProc.getImage_02
        diffImg = self.ImProc.getDiffImage

    def Callback(self, hGrabber, pBuffer, framenumber, pData):
        """:param: hGrabber: This is the real pointer to the grabber object.
        :param: pBuffer : Pointer to the first pixel's first byte
        :param: framenumber : Number of the frame since the stream started
        :param: pData : Pointer to additional user data structure"""
        image = C.cast(pBuffer, C.POINTER(C.c_ubyte * pData.buffer_size))
        cvMat = np.ndarray(buffer=image.contents,
                           dtype=np.uint8,
                           shape=(pData.height, pData.width,
                                  pData.iBitsPerPixel))
        #print("Shape pData height:", pData.height)
        #print("Shape pData width :", pData.width)
        #print("Shape pData BpP   :", pData.iBitsPerPixel)
        self.ImProc.imageProcess(cvMat)

    def setMaxIntensity(self, maxIntensity):
        self.maxIntensity = maxIntensity

    def setMinIntensity(self, minIntensity):
        self.minIntensity = minIntensity
Example #12
0
from frame import Frame
from imageProcessing import ImageProcessing
import cv2 as cv
import numpy as np
imgPlaca = cv.imread("C:/Users/oluis/Desktop/images/original/torta.png",
                     cv.IMREAD_GRAYSCALE)

plateCopy = imgPlaca.copy()

imgProcessing = ImageProcessing()

plateCopy = imgProcessing.MoreLight(plateCopy)
plateCopy = imgProcessing.Billateral(plateCopy)
plateCopy = imgProcessing.Canny(plateCopy)

findContournsImg, contoursPlate, hierarchy = cv.findContours(
    plateCopy.copy(), cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)

backtorgbplate = cv.cvtColor(plateCopy, cv.COLOR_GRAY2RGB)

for contour in contoursPlate:
    x, y, w, h = cv.boundingRect(contour)
    proportion = float(w) / h
    if proportion > 0.57 and proportion < 0.84 and h > 11:
        cv.rectangle(backtorgbplate, (x, y), (x + w, y + h), (0, 0, 255), 1)

cv.imshow('placa', backtorgbplate)

cv.waitKey(0)
Example #13
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))
Example #14
0
unit test for imageProcessing.py

"""


class TestPoint(Structure):
    _fields_ = [('ballAngle', c_int), ('ballDis', c_int)]


if __name__ == '__main__':
    TRACE('test main line')
    # テスト用共有メモリの準備
    shmem = Value(TestPoint, 0)

    imageProcessing = ImageProcessing()

    file_path = 'data/temp/camera_capture_wall_6.jpg'

    TRACE(file_path)
    stream = cv2.imread(file_path)

    ball_angle, ball_distance, station_angle, station_distance, wall_x, wall_size = imageProcessing.imageProcessingFrame(
        stream, shmem)

    cv2.imshow('Frame', cv2.flip(stream, -1))
    cv2.moveWindow('Frame', 0, 30)
    cv2.moveWindow('MaskRED', 482, 30)
    cv2.moveWindow('MaskYELLOW', 964, 30)
    cv2.moveWindow('MaskGREEN', 1446, 30)
    cv2.moveWindow('MaskBLACK', 0, 530)
Example #15
0
class TestPoint(Structure):
    _fields_ = [('irAngle', c_int), ('isTouched', c_int),
                ('enemyGoalAngle', c_int), ('enemyGoalDis', c_int),
                ('myGoalAngle', c_int), ('myGoalDis', c_int),
                ('fieldCenterAngle', c_int), ('fieldCenterDis', c_int)]


if __name__ == '__main__':
    from multiprocessing import Process, Value

    TRACE('test main line')
    # テスト用共有メモリの準備
    shmem = Value(TestPoint, 0)

    # モータ制御インスタンスの生成
    imageProcessing = ImageProcessing()

    p_imageProcessing = Process(target=imageProcessing.target, args=(shmem, ))

    file_list = glob.glob("./camera_distance/0degree/*jpg")
    TRACE(file_list)

    for file in file_list:
        TRACE(file)
        stream = cv2.imread(file)

        yellow_goal_angle, yellow_goal_distance, blue_goal_angle, blue_goal_distance, field_center_angle, field_center_distance = imageProcessing.imageProcessingFrame(
            stream, shmem)

        cv2.imshow('Frame', stream.transpose((1, 0, 2)))
        cv2.moveWindow('Frame', 0, 30)