示例#1
0
def registroDoctor():

    data = request.get_json()
    print(data)

    if not fn.checkEmail(data.get('email'), creds_dict):
        creds_aux = {
            'id:': fn.getLastID(creds_dict),
            'email': data.get('email'),
            'password': data.get('password'),
            'isDoctor': True
        }

        del data['email']
        del data['password']

        data.__setitem__('id', fn.getLastID(doctors_dict))
        data.__setitem__('userId', fn.getLastID(creds_dict))

        doctors_dict.append(data)
        creds_dict.append(creds_aux)

        fn.saveToFile(doctores, json.dumps(doctors_dict))
        fn.saveToFile(credenciales, json.dumps(creds_dict))
        return '{"response" : "Registro correcto"}'
    return '{"response" : "Correo Ocupado"}'
示例#2
0
def encodeAWholeFolderOfImagesAsSingleH264Frames(myDir):
    fileList = createFileList(myDir, takeAll=True, format='.tif')

    quants = [0, 7, 14, 21, 28, 35, 42, 49]
    #quants = [0,49]
    for quant in quants:
        # make a directory
        dirName = "quant_{}".format(quant)
        dirName = os.path.join(myDir, dirName)
        if not os.path.exists(dirName):
            os.makedirs(dirName)

        for entry in fileList:
            filename = entry[0]
            baseFileName = os.path.basename(filename)
            baseFileName, ext = os.path.splitext(baseFileName)
            baseFileName = "{}/{}".format(dirName, baseFileName)

            width, height, yuvData = functions.convertTifToYUV420(filename)
            tempYUVFilename = "myyuv.yuv"
            functions.saveToFile(yuvData, tempYUVFilename)
            print("width: {} height: {} filename:{}".format(
                width, height, filename))
            h264Filename = "{}_s{}x{}_q{}.h264".format(baseFileName, width,
                                                       height, quant)
            compYuvFilename = "{}_s{}x{}_q{}.yuv".format(
                baseFileName, width, height, quant)
            isize, psize, bsize = functions.compressFile(
                x264, tempYUVFilename, width, height, quant, h264Filename,
                compYuvFilename)
示例#3
0
def splitTraceFileIntoComponentFiles(filename, width, height):
    frameData, width, height = showBitstreamInfo.processAfile(filename,
                                                              width=width,
                                                              height=height,
                                                              noRedos=False)
    mbwidth = int(width / 16)
    mbheight = int(height / 16)
    size = int((width / 16) * (height / 16))
    frames = int(frameData.shape[0] / size)
    print("There are {} frames".format(frames))
    #print(frameData[0:(size*2), :])

    basefilename, ext = os.path.splitext(filename)
    YUVfilename = "{}.yuv".format(basefilename)
    maybeYUVfilename = "{}_ViewID0000.yuv".format(basefilename)
    if os.path.isfile(maybeYUVfilename):
        print("removing...")
        os.remove(maybeYUVfilename)
        #os.rename(maybeYUVfilename, YUVfilename)
    maybeYUVfilename = "{}_ViewID0001.yuv".format(basefilename)
    if os.path.isfile(maybeYUVfilename):
        os.remove(maybeYUVfilename)

    #frameNos = np.reshape(frameNos, (frames, mbheight, mbwidth))
    frameNos = frameData[:, 0]
    FrameNofilename = "{}.frameno".format(basefilename)
    frameNos = frameNos.flatten()
    functions.saveToFile(frameNos, FrameNofilename)

    mbNos = frameData[:, 1]
    MbNofilename = "{}.mbno".format(basefilename)
    mbNos = mbNos.flatten()
    functions.saveToFile(mbNos, MbNofilename)

    modes = frameData[:, 2]  #inter/intra
    skipped = frameData[:, 3]
    modes = (1 - modes) + skipped
    MBModefilename = "{}.mbmode".format(basefilename)
    modes = modes.flatten()
    functions.saveToFile(modes, MBModefilename)

    qps = frameData[:, 4]
    QPfilename = "{}.qp".format(basefilename)
    qps = qps.flatten()
    functions.saveToFile(qps, QPfilename)

    # motion vectors. There are 16 of them for each macroblock. x and y for every 4x4 unit.
    mvs = frameData[:, 5:]
    MVfilename = "{}.mv".format(basefilename)
    mvs = np.reshape(mvs, (frames, mbheight, mbwidth, 4, 4, 2))
    mvs = np.swapaxes(mvs, 2, 3)  # translate mbs with 4x4s into just rows
    mvs = np.reshape(mvs, (frames, mbheight * 4, mbwidth * 4, 2))
    mvs = np.swapaxes(mvs, 2,
                      3)  #this and the next line moving to 2 planar channels
    mvs = np.swapaxes(mvs, 1, 2)
    mvs = mvs.flatten() + 128
    functions.saveToFile(mvs, MVfilename)
    return width, height, frames
示例#4
0
def cambiarEstatus():
    data = request.get_json()
    id = data.get('id')
    estatus = data.get('estatus')

    fn.saveToFile(incidencias,
                  json.dumps(fn.cambiarEstatus(id, estatus, incidencias_dict)))

    return '{"respueta": "Estatus cambiado"}'
示例#5
0
def sendScore():
    data = request.get_json()
    idDoctor = data.get('idDoctor')
    score = data.get('calificacion')

    doctores_aux = fn.changeScore(idDoctor, score, doctors_dict)

    fn.saveToFile(doctores, json.dumps(doctores_aux))

    return '{"respuesta" : "Calificacion actualizada"}'
示例#6
0
def crearAsistencia():
    data = request.get_json()
    print(data)

    data.__setitem__('id', fn.getLastID(asistencia_dict))
    avisos_dict.append(data)

    fn.saveToFile(asistencia, json.dumps(asistencia_dict))

    return '{"respuesta" : "Asistencia Registrada"}'
示例#7
0
def crearIncidencia():
    data = request.get_json()
    print(data)

    data.__setitem__('id', fn.getLastID(incidencias_dict))
    incidencias_dict.append(data)

    fn.saveToFile(incidencias, json.dumps(incidencias_dict))

    return '{"respuesta" : "Incidencia Registrada"}'
示例#8
0
def crearCita():
    data = request.get_json()
    print(data)
    fecha = data.get('fecha')
    idDoctor = data.get('idDoctor')

    fechas_aux = fn.cambiarDisp(fecha, idDoctor, fechas_dict)

    data.__setitem__('id', fn.getLastID(citas_dict))

    clinica, nombre, calificacion = fn.getInfoDoctor(idDoctor, doctors_dict)
    data.__setitem__('clinica', clinica)
    data.__setitem__('nombre', nombre)
    data.__setitem__('calificacion', calificacion)

    citas_dict.append(data)

    fn.saveToFile(citas, json.dumps(citas_dict))
    fn.saveToFile(fechas, json.dumps(fechas_aux))

    return '{"respuesta" : "Cita Registrada"}'
示例#9
0
def home():
    if request.method == 'POST':
        #taking input from form and saving it to database
        category = request.form['category']
        name = request.form['name']
        char = request.form['value']
        price = request.form['price']
        img = request.files['img']
        if img.filename == "":
            flash("Nie wybrano zdjęcia")
        if img:
            filename = secure_filename(img.filename)
            img.save(os.path.join(UPLOAD_FOLDER, 'images', filename))
        find_category = Category.query.filter_by(
            category_name=category).first()
        expenses = Expenses(name, char, price, img.filename, find_category._id)
        db.session.add(expenses)
        db.session.commit()
        exp = Expenses.query.all()
        saveToFile(exp)
        saveDate()
        return redirect(url_for('finances.home'))
    else:
        all_spendings = 0
        exp = Expenses.query.all()
        cat = Category.query.all()
        category_sum = dict()
        for c in cat:
            category_sum.update({c.category_name: calculateSum(c.expenses)})
        print(category_sum)
        return render_template('wydatki.html',
                               all_spendings=category_sum,
                               category=cat,
                               expen=Expenses,
                               expenses=exp,
                               path=os.path.join('images', ""))
def processFilePair(o, a, tidyUp=False, crop=True, saveOneFrame=True):
    dims = getAVIFileDims(o)
    width, height = getDimsFromFileName(dims)
    channels = 3
    frameSize = (width * height * 3) // 2
    print("Dimensions are {} x {}, frame size {}".format(width, height, frameSize))
    oyuvname = convertAVItoYUV(o)
    ayuvname = convertAVItoYUV(a)
    print("files are {} and {}".format(oyuvname, ayuvname))

    oyuv = np.fromfile(oyuvname, 'u1')
    ayuv = np.fromfile(ayuvname, 'u1')

    #print(oyuv.shape)

    oFrame = oyuv[0:frameSize]
    aFrame = ayuv[0:frameSize]

    if crop == False:
        dims = "oneFrame_{}x{}".format(width, height)
        oCropName = o.replace(".avi", "_{}.yuv".format(dims))
        aCropName = a.replace(".avi", "_{}.yuv".format(dims))
        f.saveToFile(oFrame, oCropName)
        f.saveToFile(aFrame, aCropName)
        #return

    odata = f.YUV420_2_YUV444(oFrame, height, width)
    adata = f.YUV420_2_YUV444(aFrame, height, width)

    odata = odata.reshape((channels, height, width))
    adata = adata.reshape((channels, height, width))



    diff = abs(odata - adata)
    if saveOneFrame == True:
        diff420 = f.YUV444_2_YUV420(diff, height, width)
        maskFileName = o.replace(".avi", "_{}.yuv".format(dims))
        maskFileName = maskFileName.replace("original", "mask")
        f.saveToFile(diff420, maskFileName)

    if crop == True:
        diffY = diff[0:(width*height)]
        diffInds1 = np.nonzero(diff)
        minX = np.amin(diffInds1[2])
        maxX = np.amax(diffInds1[2])
        minY = np.amin(diffInds1[1])
        maxY = np.amax(diffInds1[1])
        print("bounding box ({},{}) to ({},{})".format(minX, minY, maxX, maxY))
        # Adjust the cropped region by adding a border
        alignTo16grid = True
        minX = addBorder(minX, width, alignTo16grid, -8)
        maxX = addBorder(maxX, width, alignTo16grid, 8)
        minY = addBorder(minY, height, alignTo16grid, -8)
        maxY = addBorder(maxY, height, alignTo16grid, 8)
        if (maxX - minX) < 96:
            maxX = minX + 96
        if (maxY - minY) < 96:
            maxY = minY + 96
        print("adjusted bounding box ({},{}) to ({},{})".format(minX, minY, maxX, maxY))

        croppedWidth = maxX - minX
        croppedHeight = maxY - minY
        dims = "cropped_{}x{}".format(croppedWidth, croppedHeight)
        odata = odata.reshape((channels, height, width))
        adata = adata.reshape((channels, height, width))
        oROI = odata[:, minY:maxY, minX:maxX]
        aROI = adata[:, minY:maxY, minX:maxX]

        # Now save the crops to a file:
        oCropName = o.replace(".avi", "_{}.yuv".format(dims))
        aCropName = a.replace(".avi", "_{}.yuv".format(dims))
        oROI420 = f.YUV444_2_YUV420(oROI, croppedHeight, croppedWidth)
        aROI420 = f.YUV444_2_YUV420(aROI, croppedHeight, croppedWidth)
        f.saveToFile(oROI420, oCropName)
        f.saveToFile(aROI420, aCropName)
        print("Made files {} and {}".format(oCropName, aCropName))

    if tidyUp:
        os.remove(oyuvname)
        os.remove(ayuvname)