当我调用二进制文件时,我需要覆盖第一个参数。
由于它是程序名称,我有两个解决方案:
但是,有时我需要完全删除第一个参数。
我在C中编写了一个简单的程序来完成这项工作:
import pandas as pd
link_energy = 'http://unstats.un.org/unsd/environment/excel_file_tables/2013/Energy%20Indicators.xls'
df_energy = pd.read_excel(link_energy)
df_energy
我有一个内置的方法来做shell吗?首选bash的解决方案。
答案 0 :(得分:5)
您可以使用busybox
覆盖它,但不能设置它。
例如,要将argv[0]
设置为ls
来运行( exec -a ls busybox )
:
import cv2
import sys
(major_ver, minor_ver, subminor_ver) = (cv2.__version__).split('.')
img = cv2.imread('OXO200Front.jpg')
if __name__ == '__main__' :
# Set up tracker.
# Instead of MIL, you can also use
tracker_types = ['BOOSTING', 'MIL','KCF', 'TLD', 'MEDIANFLOW', 'GOTURN']
tracker_type = tracker_types[2]
if int(minor_ver) < 3:
tracker = cv2.Tracker_create(tracker_type)
else:
if tracker_type == 'BOOSTING':
tracker = cv2.TrackerBoosting_create()
if tracker_type == 'MIL':
tracker = cv2.TrackerMIL_create()
if tracker_type == 'KCF':
tracker = cv2.TrackerKCF_create()
if tracker_type == 'TLD':
tracker = cv2.TrackerTLD_create()
if tracker_type == 'MEDIANFLOW':
tracker = cv2.TrackerMedianFlow_create()
if tracker_type == 'GOTURN':
tracker = cv2.TrackerGOTURN_create()
cap = cv2.VideoCapture(0)
ok, frame = cap.read()
#Initializing a bounding box
bbox = img
bbox = cv2.selectROI(frame, False)
ok = tracker.init(frame, bbox)
while(1):
ok, frame = cap.read()
timer = cv2.getTickCount()
ok, bbox = tracker.update(frame)
fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer);
if ok:
p1 = (int(bbox[0]), int(bbox[1]))
p2 = (int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3]))
cv2.rectangle(frame, p1, p2, (255,0,0), 2, 1)
else :
# Tracking failure
cv2.putText(frame, "Tracking failure detected", (100,80),
cv2.FONT_HERSHEY_SIMPLEX, 0.75,(0,0,255),2)
cv2.putText(frame, tracker_type + " Tracker", (100,20),
cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50,170,50),2);
# Display FPS on frame
cv2.putText(frame, "FPS : " + str(int(fps)), (100,50),
cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50,170,50), 2);
# Display result
cv2.imshow("Tracking", frame)
K = cv2.waitKey(1)
if (K==27):
break
cap.release()
cv2.destroyAllWindows()