我有一个应用程序,我使用intent发送电子邮件,如下所示:
//TODO attach and send here
try {
Log.i(getClass().getSimpleName(), "send task - start");
String address = "emailHere@yahoo.com";
String subject = "Order of " + customer + " for " + date;
String emailtext = "Please check the attached file. Attached file contains order of " + customer;
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { address });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext);
ArrayList<Uri> uris = new ArrayList<Uri>();
Uri uriList = Uri.fromFile(orderListFile);
uris.add(uriList);
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
} …Run Code Online (Sandbox Code Playgroud) 我一直在试图检测照片中的人,而且我对行人有一些成功.但是,对于我的用例场景,我需要能够检测照片中的半身/上身(腰部向上)或头部.
我尝试了上半身的哈尔级联.这是我使用的代码:
import numpy as np
import cv2
img = cv2.imread('/path/to/img.jpg',0)
upperBody_cascade = cv2.CascadeClassifier('path/to/haarcascade_upperbody.xml')
arrUpperBody = upperBody_cascade.detectMultiScale(img)
if arrUpperBody != ():
for (x,y,w,h) in arrUpperBody:
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
print 'body found'
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
我用了3张测试图像.请注意,它是相同的图像,在特定级别裁剪.
以下是我得到的结果:
如您所见,Knee Up和Chest Up照片分别能够检测到上半身和头部区域.
然而,即使上身和头部可见,腰部以上的照片也没有任何结果.
有谁知道这种情况发生的原因和原因以及可以采取哪些措施使上身检测更加一致?
我正在pdfgrep搜索PDF文档中关键字的所有外观。
现在,我想通过PHP执行此操作,以便可以在我的网站中使用它。
但是,当我运行时:
$output = shell_exec("pdfgrep -i $keyword $file");
$var_dump($output);
Run Code Online (Sandbox Code Playgroud)
$keyword关键字和$file文件在哪里,我没有得到全部输出。
PDF由产品代码,产品名称和产品价格表组成。
通过终端执行命令时,可以看到整行数据:
product code 1 product name with keyword substring corresponding price
product code 2 product name with keyword substring corresponding price
product code 3 product name with keyword substring corresponding price
Run Code Online (Sandbox Code Playgroud)
但是,当我通过PHP运行它时,我得到如下信息:
name with keyword substring with keyword substring product code 1
product name with keyword substring product name with keyword substring
corresponding price
Run Code Online (Sandbox Code Playgroud)
它只是不获取所有数据。它并不总是获得产品代码和价格,并且在很多情况下也没有获得整个产品名称。
我通过浏览器查看输出并放入,header('Content-Type: text/plain');但是它只能美化输出,数据仍然不完整。
我试图通过Python3.6运行完全相同的shell脚本,这给了我所需的输出。
现在,我尝试通过PHP运行相同的Python脚本,但仍然得到相同的损坏输出。
我尝试运行一个我知道会返回较短输出的关键字,但是我仍然没有得到所需的整个数据行。
有什么方法可以可靠地获取 …
美好的一天.我有一个使用包含五个数据库表的数据库的应用程序,我想要做的是能够将其中两个表导出为CSV文件并通过电子邮件发送它们.在进行初步研究时,我发现OpenCSV库是将SQLite表导出为CSV的流行选择.但是,经过进一步的研究,我看到导出通过给函数提供一个ResultSet对象来writeAll(ResultSet rSet, Boolean includeHeaders)工作,但是,没有明确地显示如何获得ResultSet.我试图寻找有关如何在DatabaseHelper类中使用ResultSet的指南,但我提出了空白.
谁能教我如何在我的DatabaseHelper类中实现一个函数来返回查询结果的ResultSet?这是我的DatabaseHelper类:
public class OrderListDBAdapter {
private DatabaseHelper mDBHelper;
private SQLiteDatabase mDB;
private final Context context;
private static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context) {
super(context, "itemList.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
public OrderListDBAdapter(Context context){
this.context = context;
}
public OrderListDBAdapter open() throws SQLException{
this.mDBHelper = new DatabaseHelper(this.context);
//this.mDB = this.mDBHelper.getWritableDatabase(DBAdapter.key);
this.mDB = …Run Code Online (Sandbox Code Playgroud) 美好的一天.我的Android应用程序中有一个AutoCompleteTextView,它运行正常.但是,我注意到这些建议是基于提供给AutoCompleteTextView的列表的子串的第一个字符.这本身很好,但是,我想要的是它还显示包含用户输入的项目.
例如,让我们使用此列表:
然而,打字ad会建议Adipose我也想Bad Wolf提出建议,因为它包含ad在Bad.这不会发生,因为AutoCompleteTextView只查看列表项中的子字符串的开头(子字符串由空格分隔),而不是在这些子字符串中.
是否有任何方法可以使AutoCompleteTextViews建议包含输入文本的项目,无论该文本在列表项目中的位置如何?
谢谢你的帮助.
编辑/ UPDATE
请参阅下面的pskink评论.我尝试实现如下相同的解决方案.
我所推断的逻辑是a SimpleCursorAdapter将被使用,而不是常见的ArrayAdater.然后我创建了一个FilterQueryProvider到SimpleCursorAdapter.使用runQuery方法FilterQueryProvider,我现在可以通过搜索用户的约束输入列表来运行过滤算法.这是代码:
//initialize the ACTV
AutoCompleteTextView search = (AutoCompleteTextView) findViewById(R.id.actvCatalogueSearch);
search.setThreshold(1); //set threshold
//experiment time!!
//I honestly don't know what this is for
int[] to = { android.R.id.text1 };
//initializing the cursorAdapter.
//please note that pdflist is the array I used for the ACTV value
SimpleCursorAdapter …Run Code Online (Sandbox Code Playgroud) 我正在尝试复制我已经在iOS上制作的Android应用程序.我正在尝试创建一个BLE应用程序,我的iOS设备可以看到并连接到BLE设备并获得RSSI(我真的不关心消息和其他数据).通过搜索研究,我在iOS开发人员库中找到了这个BLTE Central Peripheral Transfer示例.下载后,打开XCode项目,然后运行它.但是,在使用此代码后,我遇到了一个错误:
if (!self.discoveredPeripheral.isConnected) {
return;
}
Run Code Online (Sandbox Code Playgroud)
错误在哪里: Property 'isConnected' not found on object of type 'CBPeripheral'
再次搜索时,我找到了这个链接.但是,似乎该线程没有任何解决方案,因为所讨论的答案似乎也被弃用了.我似乎也找不到任何解决这个问题的方法.
有没有人试图让iOS开发者库中的代码工作?
我一直在构建此DialogFlow,并已在我的平板电脑设备上对其进行了测试。我之前已将语言设置为英语(美国)来访问它。打开Google助手后,我说了“与”对话,这将拉起我的自定义Google助手。我可以使用Android平板电脑进行测试和调试。
但是,当我刚刚尝试测试时,它告诉我“我的自定义Google助手”在为您的语言或国家/地区设置的设备上不可用。我没有改变平板电脑的设置,也没有改变我的DialogFlow或Google Actions。
奇怪的是,如果我输入“ Talk to”,我就能使用我的助手与之交谈。
我不确定我的设备或“自定义Google助手”出了什么问题。在Google的“操作”中对其进行测试,然后通过语音提示致电“自定义Google助手”。
我正试图让OpenCV在图像中检测到一张床.我正在运行通常的灰度,模糊,Canny,我尝试过Convex Hull.然而,由于存在相当多的"噪音",这会产生额外的轮廓并且会弄乱物体检测.因此,我无法正确检测床.
这是输入图像以及Canny边缘检测结果:
如你所见,它几乎就在那里.我已经有了床的轮廓,尽管右上角有一个间隙 - 这使我无法检测出一个封闭的矩形.
这是我正在运行的代码:
import cv2
import numpy as np
def contoursConvexHull(contours):
print("contours length = ", len(contours))
print("contours length of first item = ", len(contours[1]))
pts = []
for i in range(0, len(contours)):
for j in range(0, len(contours[i])):
pts.append(contours[i][j])
pts = np.array(pts)
result = cv2.convexHull(pts)
print(len(result))
return result
def auto_canny(image, sigma = 0.35):
# compute the mediam of the single channel pixel intensities
v = np.median(image)
# apply automatic Canny edge detection using the computed median
lower …Run Code Online (Sandbox Code Playgroud) 我有这个函数,它从数据库查询中获取结果.我正在使用FMDB库来查询数据库.但是,我感觉我没有正确地将查询结果传输到我的可变数组.这是我的功夫
-(NSArray *)initializeGroupIDArray{
// Getting the database path.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *dbPath = [docsPath stringByAppendingPathComponent:@"itemList.db"];
FMDatabase *database = [FMDatabase databaseWithPath:dbPath];
[database open];
NSString *sqlSelectQuery = @"SELECT DISTINCT GROUPID FROM ItemList";
// Query result
FMResultSet *resultsWithNameLocation = [database executeQuery:sqlSelectQuery];
while([resultsWithNameLocation next]) {
NSString *itemName = [NSString stringWithFormat:@"%@",[resultsWithNameLocation stringForColumn:@"GROUPID"]];
// loading your data into the array, dictionaries.
NSLog(@"GroupID = %@", itemName);
[groupArray addObject:itemName];
}
[database close];
NSArray *groupID;
[groupID = groupArray copy];
return …Run Code Online (Sandbox Code Playgroud) 我一直在开发这个应用程序,该应用程序应该每天在给定时间运行(周末除外)。我使用了AlarmBroadCastReceiver在给定时间触发特定代码块。我的AlarmBroadCastReceiver班级中有这样的代码:
public void SetAlarm(Context context) {
AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class);
intent.putExtra(ONE_TIME, Boolean.FALSE);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 2);
calendar.set(Calendar.MINUTE, 30);
calendar.set(Calendar.SECOND, 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 0, pi);
}
Run Code Online (Sandbox Code Playgroud)
基本上我会尝试在那个时间设置一个重复闹钟。
然后按一下按钮,我就可以在 MainActivity 中调用它:
public void onStartAlarmClicked(View view){
Context context = this.getApplicationContext();
if(alarm != null){
Log.e(TAG, "starting alarm");
alarm.SetAlarm(context);
}else{
Log.e(TAG, "Alarm is null");
}
}
Run Code Online (Sandbox Code Playgroud)
其中alarm是类的对象AlarmBroadCastReceiver。
我遇到的问题是代码只触发一次。一旦到达 2:30,它就会开火。但是,当我将时间设置回 2:29 并等待 2:30,或者将日期向前设置 1 …
android ×5
opencv ×2
python ×2
alarmmanager ×1
email ×1
ios ×1
iphone ×1
objective-c ×1
opencv3.0 ×1
opencv3.1 ×1
php ×1
python-2.7 ×1
python-3.x ×1
resultset ×1
shell-exec ×1
sqlite ×1
terminal ×1