コード例 #1
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
def SetCurve(session, curve):
    """Send the curve to the camera
    
    Arguments:
    session -- The PtpSession."""

    ptp_request = PtpSession.PtpRequest(PtpValues.NikonOperations.SET_CURVE,
                                        session.sessionid,
                                        session.NewTransaction())
    (ptp_response,
     rx) = session.transport.ptp_simple_transaction(ptp_request,
                                                    tx_data=curve.pack())
    if ptp_response.respcode != PtpValues.StandardResponses.OK:
        raise PtpSession.PtpException(ptp_response.respcode)
コード例 #2
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
def AutoFocus(session):
    """Automatically focus the device.
    
    Arguments:
    session -- The PtpSession."""

    ptp_request = PtpSession.PtpRequest(PtpValues.NikonOperations.AUTO_FOCUS,
                                        session.sessionid,
                                        session.NewTransaction())
    (ptp_response,
     rx) = session.transport.ptp_simple_transaction(ptp_request,
                                                    receiving=False)
    if ptp_response.respcode != PtpValues.StandardResponses.OK:
        raise PtpSession.PtpException(ptp_response.respcode)
コード例 #3
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
def DisableBodyControls(session, body_control):
    """Disable/enable camera body controls
    
    Arguments:
    session -- The PtpSession
    control_mode -- The camera control mode to set."""

    ptp_request = PtpSession.PtpRequest(
        PtpValues.NikonOperations.DISABLE_BODY_CONTROLS, session.sessionid,
        session.NewTransaction(), (body_control, ))
    (ptp_response,
     rx) = session.transport.ptp_simple_transaction(ptp_request,
                                                    receiving=False)
    if ptp_response.respcode != PtpValues.StandardResponses.OK:
        raise PtpSession.PtpException(ptp_response.respcode)
コード例 #4
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
def GetThumbMedium(session, objectHandle, stream=None):
    """Get a medium sized thumbnail.
    
    Arguments:
    session -- The PtpSession.
    objectid -- The objectid concerned."""

    ptp_request = PtpSession.PtpRequest(
        PtpValues.NikonOperations.GET_THUMB_MEDIUM, session.sessionid,
        session.NewTransaction(), (objectHandle, ))
    session.transport.send_ptp_request(ptp_request)
    rx_data = session.transport.get_ptp_data(ptp_request, stream)
    ptp_response = session.transport.get_ptp_response(ptp_request)
    if ptp_response.respcode != PtpValues.StandardResponses.OK:
        raise PtpSession.PtpException(ptp_response.respcode)
    return rx_data
コード例 #5
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
def GetCurve(session):
    """Retrieve the curve from the camera
    
    Arguments:
    session -- The PtpSession."""

    ptp_request = PtpSession.PtpRequest(PtpValues.NikonOperations.GET_CURVE,
                                        session.sessionid,
                                        session.NewTransaction())
    (ptp_response,
     rx) = session.transport.ptp_simple_transaction(ptp_request,
                                                    receiving=True)
    if ptp_response.respcode != PtpValues.StandardResponses.OK:
        raise PtpSession.PtpException(ptp_response.respcode)

    return NikonCurveInfo(rx[1])
コード例 #6
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
def RamCapture(session):
    """Capture a picture and leave it in the camera's RAM. Does not autofocus.
    
    Arguments:
    session -- The PtpSession."""

    # The meaning of the parameter is unknown: 0xffffffff captures into RAM. 0 captures, but doesn't appear to actually save the image
    ptp_request = PtpSession.PtpRequest(PtpValues.NikonOperations.RAM_CAPTURE,
                                        session.sessionid,
                                        session.NewTransaction(),
                                        (0xffffffff, ))
    (ptp_response,
     rx) = session.transport.ptp_simple_transaction(ptp_request,
                                                    receiving=False)
    if ptp_response.respcode != PtpValues.StandardResponses.OK:
        raise PtpSession.PtpException(ptp_response.respcode)
コード例 #7
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
def CheckEvents(session):
    """Check events on the camera -- e.g. Nikon doesn't appear to report property change events over the standard IRQ pipe."""

    ptp_request = PtpSession.PtpRequest(PtpValues.NikonOperations.CHECK_EVENTS,
                                        session.sessionid,
                                        session.NewTransaction())
    (ptp_response,
     rx) = session.transport.ptp_simple_transaction(ptp_request,
                                                    receiving=True)
    if ptp_response.respcode != PtpValues.StandardResponses.OK:
        raise PtpSession.PtpException(ptp_response.respcode)

    unpacker = PtpSession.PtpUnpacker(rx[1])
    events = ()
    for i in xrange(0, unpacker.unpack("<H")[0]):
        (code, param) = unpacker.unpack("<HI")
        events += (PtpAbstractTransport.PtpEvent(code, 0xffffffff, 0xffffffff,
                                                 (param, )), )
    return events
コード例 #8
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
    def __init__(self, raw):
        unpacker = PtpSession.PtpUnpacker(raw)

        (data_length, unknown, self.xaxis_start, self.xaxis_end,
         self.yaxis_start, self.yaxis_end, self.midpoint_integer,
         self.midpoint_decimal, coordcount) = unpacker.unpack("<IHBBBBBBB")

        self.coordinates = ()
        while coordcount:
            self.coordinates += (unpacker.unpack("<BB"), )
            coordcount -= 1
コード例 #9
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
    def pack(self):
        packer = PtpSession.PtpPacker()

        packer.pack("<IHBBBBBBB", 2116, 24393, self.xaxis_start,
                    self.xaxis_end, self.yaxis_start, self.yaxis_end,
                    self.midpoint_integer, self.midpoint_decimal,
                    len(self.coordinates))
        for c in self.coordinates:
            packer.pack("<BB", c[0], c[1])

        # FIXME: The rest of the file is unknown

        return packer.raw
コード例 #10
0
ファイル: NikonSupport.py プロジェクト: jwcondor/FocusStack
def PollStatus(session):
    """Poll the status of the device (e.g. for monitoring ASYNC operations such as autofocus or capture).
    
    Arguments:
    session -- The PtpSession."""

    ptp_request = PtpSession.PtpRequest(PtpValues.NikonOperations.POLL_STATUS,
                                        session.sessionid,
                                        session.NewTransaction())
    (ptp_response,
     rx) = session.transport.ptp_simple_transaction(ptp_request,
                                                    receiving=False)
    return ptp_response.respcode