我在python中使用list时遇到了问题。我将三个具有不同形状的all_dets
附加到循环中名为 for i in range(3):
print 'detecting on image', image_paths[i] + ext
im = cv2.imread(image_paths[i] + ext)
print 'im.shape =', im.shape
blobs_out = im_detect(net, im)
print 'type(blobs_out) = ', type(blobs_out)
print 'blobs_out.shape = ', blobs_out.shape
all_dets.append(im_detect(net, im))
# the following statement works correctly, but I don't know why
# all_dets.append(np.array(im_detect(net, im), dtype=float))
print all_dets[i], '\n'
print '\n\n'
for i in range(len(all_dets)):
print all_dets[i], '\n'
的列表中。然后我逐一打印出这个列表中的元素,发现元素完全错了!以下是相关代码:
detecting on image 2901.jpg
im.shape = (720, 1280, 3)
type(blobs_out) = <type 'numpy.ndarray'>
blobs_out.shape = (2, 6)
[[ 3.00000000e+00 7.23988281e+02 1.99807007e+02 8.51956665e+02
3.57274475e+02 9.98903632e-01]
[ 3.00000000e+00 9.50594910e+02 2.12917633e+02 1.09674084e+03
3.62154694e+02 9.97807443e-01]]
detecting on image 2902.jpg
im.shape = (720, 1280, 3)
type(blobs_out) = <type 'numpy.ndarray'>
blobs_out.shape = (1,)
[ 3.]
detecting on image 2903.jpg
im.shape = (720, 1280, 3)
type(blobs_out) = <type 'numpy.ndarray'>
blobs_out.shape = (11, 6)
[[ 1.00000000e+00 7.94668335e+02 2.84922882e+02 9.72878418e+02
4.09533173e+02 9.99811232e-01]
[ 1.00000000e+00 6.11299622e+02 2.81592804e+02 6.46697083e+02
3.24412018e+02 9.47641492e-01]
[ 3.00000000e+00 6.53184875e+02 2.65788025e+02 6.84356262e+02
3.08493958e+02 9.21398461e-01]
[ 7.00000000e+00 6.95969604e+02 3.98138847e+01 7.36190674e+02
7.37466125e+01 9.90691066e-01]
[ 7.00000000e+00 6.01833191e+02 0.00000000e+00 6.43418640e+02
3.40718689e+01 9.90287900e-01]
[ 7.00000000e+00 8.83409363e+02 3.55691872e+01 9.16870911e+02
6.30310249e+01 9.87128615e-01]
[ 7.00000000e+00 5.53889893e+02 7.42240906e-01 5.93223389e+02
3.85933495e+01 9.80867684e-01]
[ 7.00000000e+00 5.55981384e+02 4.44181366e+01 5.94018616e+02
8.16374359e+01 9.77178693e-01]
[ 7.00000000e+00 6.07572449e+02 4.32948265e+01 6.37179382e+02
7.26311188e+01 9.76257086e-01]
[ 7.00000000e+00 8.35696045e+02 3.56059189e+01 8.70543091e+02
7.16980743e+01 9.62459803e-01]
[ 7.00000000e+00 7.46284302e+02 3.84980392e+01 7.80992798e+02
6.67527924e+01 9.32877839e-01]]
[[ 1.00000000e+00 7.94668335e+02 2.84922882e+02 9.72878418e+02
4.09533173e+02 9.99811232e-01]
[ 1.00000000e+00 6.11299622e+02 2.81592804e+02 6.46697083e+02
3.24412018e+02 9.47641492e-01]]
[ 1.]
[[ 1.00000000e+00 7.94668335e+02 2.84922882e+02 9.72878418e+02
4.09533173e+02 9.99811232e-01]
[ 1.00000000e+00 6.11299622e+02 2.81592804e+02 6.46697083e+02
3.24412018e+02 9.47641492e-01]
[ 3.00000000e+00 6.53184875e+02 2.65788025e+02 6.84356262e+02
3.08493958e+02 9.21398461e-01]
[ 7.00000000e+00 6.95969604e+02 3.98138847e+01 7.36190674e+02
7.37466125e+01 9.90691066e-01]
[ 7.00000000e+00 6.01833191e+02 0.00000000e+00 6.43418640e+02
3.40718689e+01 9.90287900e-01]
[ 7.00000000e+00 8.83409363e+02 3.55691872e+01 9.16870911e+02
6.30310249e+01 9.87128615e-01]
[ 7.00000000e+00 5.53889893e+02 7.42240906e-01 5.93223389e+02
3.85933495e+01 9.80867684e-01]
[ 7.00000000e+00 5.55981384e+02 4.44181366e+01 5.94018616e+02
8.16374359e+01 9.77178693e-01]
[ 7.00000000e+00 6.07572449e+02 4.32948265e+01 6.37179382e+02
7.26311188e+01 9.76257086e-01]
[ 7.00000000e+00 8.35696045e+02 3.56059189e+01 8.70543091e+02
7.16980743e+01 9.62459803e-01]
[ 7.00000000e+00 7.46284302e+02 3.84980392e+01 7.80992798e+02
6.67527924e+01 9.32877839e-01]]
这是输出,数据显示不一致。为什么?这是一个错误吗?
else if(preference.getKey().equals("logout")){
AlertDialog.Builder alt_logout = new AlertDialog.Builder(activity);
alt_logout.setMessage("Do You want to logout?");
alt_logout.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// Action for 'Yes' Button
Intent Logout = new Intent(SettingActivity.this, LoginActivity.class);
startActivity(Logout);
}
});
alt_logout.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'NO' Button
dialog.cancel();
}
});
AlertDialog alert
= alt_logout.create();
// Title for Alet Dialog
alert.setTitle("Logout");
alert.show();
}