Python程序Airnef在下载图片时卡住了

2024-09-28 12:13:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Airnef通过python从我的佳能单反相机下载图片。在

我可以下载一张图片没有问题,所以整个设置似乎工作。但是,一旦我想下载另一个图像,软件就会挂起。代码在我看来相当复杂。在

两个月前我在TestCams.com网站. 因为我还没有得到回应,所以我把它作为一个与python相关的问题发布在这里。在

线

我从命令行启动airnef。在

python airnefcmd.py --ipaddress 192.168.188.84 --action getfiles --realtimedownload only --downloadexec open @pf@ --transferorder newestfirst --outputdir "/Users/besi/Desktop"

我连接了摄像头,显示了一些关于连接的信息:

Connection established to 192.168.188.84:15740
Camera Model “Canon EOS 200D”, S/N “XXXXXXXXX”

现在艾尔内夫告诉我:

Waiting for realtime photos from camera to download.
Press to exit |

我拍了张照片,它会按预期下载:

Downloading “IMG_0084.JPG”: 96%

Airnef随后显示了有关此图像的更多信息:

/Users/besi/Desktop/IMG_0084.JPG [size = 4,602,357] in 1.94 seconds (2.26 MB/s)

我又拍了一些照片,但没有下载,软件在提示下卡住了:

Waiting for realtime photos from camera to download. Press to exit \

源代码

源代码可以在Airnef网站上找到。我创建了一个github存储库来解决这个问题:https://github.com/besi/airnef

代码被卡住的地方是airnefcmd.py:3203

更新:论坛帖子

这是指向forum post on testcams.com的链接

更新:调试

第一个名为IMG_was downloaded的图像成功。在

在调试输出中,我可以看到正在拍摄一张新照片,但下载被跳过,因为先前的图像已经下载:

参见airnef.log:433

^{pr2}$

找到一个名为IMG_0183.JPG的新图像。在

Skipping IMG_0182.JPG - already downloaded this session  

旧的下载图像似乎阻止了对当前图像的进一步处理。在

Skipping 100CANON - object is not file - MTP_OBJFORMAT_Assocation (0x3001)
Skipping DCIM - object is not file - MTP_OBJFORMAT_Assocation (0x3001)
Waiting for realtime photos from camera to download. Press <ctrl-c> to exit -execMtpOp: MTP_OP_GetObjectHandles - CmdReq payload:

现在我们又回到了等待更多图片的循环中。 当拍摄一张新照片时,同样的过程会再次发生。在


Tags: tofrom图像comimgfor图片照片
1条回答
网友
1楼 · 发布于 2024-09-28 12:13:53

我没有一个兼容的摄像头,所以我只根据论坛上发布的日志(在调试模式)来回答。
另外,在一条评论中,这是一个反复试验的建议,因此它不是“科学”的方法(即确定原因,然后修复)。
需要一个团队(@Besi和我)的努力才能得出这个答案(并且应该相应地划分积分)。在

根据日志,这两个文件的处理方式不同:

...

filename = DCIM\100CANON\IMG_0182.JPG
captureDateSt = 20180926T071747
modificationDateStr= 20180926T071748
Download history file “/Users/besi/Library/Application Support/airnef/appdata/Canon EOS 200D-SN59074c1578e347a3bf1f6f85e8dec624-downloadhist” loaded – 53 entries
>> MTP_OP_GetObject
Downloading “IMG_0182.JPG”: 0%IMG_0182.JPG – downloading next piece, offset=0x0, count=0x100000

...

ilename = DCIM\100CANON\IMG_0183.JPG
captureDateSt = 20180926T071759
modificationDateStr= 20180926T071758
Skipping IMG_0182.JPG – already downloaded this session
Skipping 100CANON – object is not file – MTP_OBJFORMAT_Assocation (0x3001)
Skipping DCIM – object is not file – MTP_OBJFORMAT_Assocation (0x3001)
Waiting for realtime photos from camera to download. Press <ctrl-c> to exit -execMtpOp: MTP_OP_GetObjectHandles – CmdReq payload:

...

正如在处理2nd文件(IMG_0183.JPG)时所见,1stone(IMG_0182.JPG)会触发所有内容被放弃。在

浏览[TestCams]: airnef - Wireless download from your Nikon Camera!,其中一个命令行参数(实际上,我建议了更多)引起了我的注意:
rtd\_mtppollingmethod\_newobjdetection,我建议指定numobjs(因此,覆盖默认值)。显然,这是(主要)问题。
另一部分是 transferorder newestfirst的存在。默认情况下,在实时下载模式下,设置为oldestfirst(见下文)。删除它(或者冗余地指定 transferorder oldestfirst)就达到了目的。在

结论

为了解决这个问题,有两件事是必要的(就命令行args for空军司令部.py):

  • 指定 rtd_mtppollingmethod_newobjdetection numobjs
  • 删除 transferorder newestfirst

根据[GitHub]: besi/airnef - (master) airnef/airnefcmd.py: 3403

g.args['transferorder'] = 'oldestfirst'     # so that downloadMtpFileObjects() will properly enumerate through multiple realtime images as we add them

我认为这是airnef方面的一个bug(关于transferorder)。它位于任何一个地方

  • 代码:当处于实时模式时,应忽略transferorder
  • Doc:指定 transferorder newestfirst实时模式不兼容

相关问题 更多 >

    热门问题