• python: WindowsError: [Error 193] %1 is not a valid windows32 application
    2 replies, posted
[quote] C:\Users\Bas\Desktop\kenect>C:\Users\Bas\Desktop\kenect\getSnapshot.py Traceback (most recent call last): File "C:\Users\Bas\Desktop\kenect\getSnapshot.py", line 191, in <module> main() File "C:\Users\Bas\Desktop\kenect\getSnapshot.py", line 153, in main initKinect() File "C:\Users\Bas\Desktop\kenect\getSnapshot.py", line 52, in initKinect kinect = ctypes.cdll.CLNUIDevice File "C:\Python27\lib\ctypes\__init__.py", line 423, in __getattr__ dll = self._dlltype(name) File "C:\Python27\lib\ctypes\__init__.py", line 353, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 193] %1 is not a valid windows32 application[/quote] does anyone know how to fix this? it have this error with almost every python script. [editline]17th February 2011[/editline] just in case anyone is inerested in the code: [code]# Requires at least Python 2.5, PIL # a Kinect, and CL NUI drivers from http://codelaboratories.com/get/nui # By Nathan Viniconis # You can use this code freely without any obligation to the original or myself import ctypes import time import Image import math import sys import os ####################### # Editable globals ####################### # base file names to be used to store the depth and color info. colorImageName = "OutputColor" # .png depthImageName = "OutputDepth" # .tiff saveDir = "F:\\Programming\\Talon\\Kinect\\Images\\Try3\\" colorDir = "Color\\" depthDir = "Depth\\" # number of images to take numImages = 100 # seconds to start before capturing.. (used to get in position in time!) startWait = 5 # less than 2 causes wierd results # seconds to wait between the images imageWait = 0 ########################### ## Global inits ########################### curImageIndex = 0 maxDigits = 5 # 00000 to 99999 should be plenty # Kinect frame buffers kinectDataImages = [] # Init the Kinect kinect = None camera = None # Initializes all the variables for the kinect def initKinect(): global kinect global camera kinect = ctypes.cdll.CLNUIDevice serial = kinect.GetNUIDeviceSerial(0) camera = kinect.CreateNUICamera(serial) if (str(camera) == "0"): print "could not connect to kinect" sys.exit(0) # starts the cameras so that frames can be extracted def startKinect(): kinect.StartNUICamera(camera) # stops the camera, call before closing or it can freeze def endKinect(): kinect.StopNUICamera(camera) kinect.DestroyNUICamera(camera) def doStartWait(): curSec = 0 while (curSec < startWait): startingIn = startWait - curSec print "Starting in " + str(startingIn) + " sec." # wait in 1 second intervals so we can have a countdown if (startingIn >= 0): time.sleep(1) else: time.sleep(startingIn) curSec += 1 print "Starting! GOGOGO..." # Create the filenames to use def getFilenamesFromIndex(): global curImageIndex prefix = "" if (len(str(curImageIndex)) < maxDigits): numZeros = maxDigits - len(str(curImageIndex)) while (numZeros > 0): prefix = "0" + prefix numZeros -= 1 clrImage = saveDir + colorDir + prefix + str(curImageIndex) + colorImageName + ".png" dpthImage = saveDir + depthDir + prefix + str(curImageIndex) + depthImageName + ".tiff" return clrImage, dpthImage # find the index to use so each image independently so that they are not overwritten def getFilenamesToUse(): global curImageIndex clrFileUsed = True depthFileUsed = True while clrFileUsed or depthFileUsed: # see if either the depth or color index has already been used fileNames = getFilenamesFromIndex() # check the two files clrFileUsed = os.path.exists(fileNames[0]) depthFileUsed = os.path.exists(fileNames[1]) # if either exist, try the next index if (clrFileUsed or depthFileUsed): curImageIndex += 1 return getFilenamesFromIndex() # actually take the snapshots def takeSnapshot(): # create some buffers to hold the images clrBuffer = ctypes.create_string_buffer(640*480*3) dpthBuffer = ctypes.create_string_buffer(640*480*2) # Get the Kinect data kinect.GetNUICameraColorFrameRGB24(camera, clrBuffer) kinect.GetNUICameraDepthFrameRAW(camera, dpthBuffer) # add these images to the list kinectDataImages.append( (clrBuffer,dpthBuffer) ) # save the stored images to the disk def saveImages(): for dataImages in kinectDataImages: # get the filenames to store the data into fileNames = getFilenamesToUse() # Output with PIL clrImage = Image.fromstring('RGB', [640, 480], dataImages[0], 'raw', 'BGR', 0, 1) clrImage.save(fileNames[0]) dpthImage = Image.fromstring('I;16', [640, 480], dataImages[1]) dpthImage.save(fileNames[1]) def main(): # todo: make sure the image directories exist, and if they do not, create them! # turn on the kinect initKinect() startKinect() # find the initial image index to use getFilenamesToUse() # start the initial amount of time required doStartWait() # start the FPS counter thingy startTime = time.clock() # take the images imagesTaken = 0 while (imagesTaken < numImages): # a sleep(0) causes priority to be given to other threads.. skip if 0 if (imageWait > 0): time.sleep(imageWait) takeSnapshot() imagesTaken += 1 # all images taken, record time endTime = time.clock() passedTime = endTime - startTime FPS = float(numImages) / passedTime print "\n\n\nFPS: " + str(FPS) print "numImages: " + str(float(numImages)) + " // " + str(passedTime) # actually save the images to the disk saveImages() # turn off the kinect (can crash with 1210 drivers.. do last) endKinect() if __name__ == "__main__": main() [/code]
Try here [url]http://www.facepunch.com/forums/240-Programming[/url]
i'l repost there
Sorry, you need to Log In to post a reply to this thread.