convert

Convert image document to black and white with OpenCV

匿名 (未验证) 提交于 2019-12-03 02:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm new to OpenCV and image processing and I'M not sure how to solve my problem. I have a photo of document made in iPhone and I want to convert that document to black and white. I tried to use threshold but the text was not so good (a little blurry and unreadable). I'd like to text looks same as on the original image, only black, and background will be white. What can I do? P.S. When I made a photo of part of the document, where text is quite big, then result is ok. I will be grateful for any help. Here are the example image I use

convert file to base64 function output

匿名 (未验证) 提交于 2019-12-03 02:21:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Public Function ConvertFileToBase64(ByVal fileName As String) As String Dim ReturnValue As String = "" If My.Computer.FileSystem.FileExists(fileName) Then Using BinaryFile As FileStream = New FileStream(fileName, FileMode.Open) Dim BinRead As BinaryReader = New BinaryReader(BinaryFile) Dim BinBytes As Byte() = BinRead.ReadBytes(CInt(BinaryFile.Length)) ReturnValue = Convert.ToBase64String(BinBytes) BinaryFile.Close() End Using End If Return ReturnValue End Function The questions I want to ask: I want the output that is I want to convert a

How to convert time format into milliseconds and back in Python?

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The reason is because I'm making a script to work with ffmpeg and I need to be able to add/subtract time in the format 00:00:00[.000] The last 3 digits are optional and they mean milliseconds. A time string could look like any of the following 4:34.234 5.000 2:99:34 4:14 This would be easier if a lot of the digits weren't optional. But since they are, I'm thinking I have to use some sort of regex to parse it? 回答1: From string to milliseconds: s = "4:34.234" hours, minutes, seconds = (["0", "0"] + s.split(":"))[-3:] hours = int(hours) minutes

Convert C to PHP for CRC16 Function

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I need help in converting C code into PHP. The following is the C Code: static const U16 crctab16 [] = { 0x0000 , 0x1189 , ... }; U16 GetCrc16 ( const U8 * pData , int nLength ) { U16 fcs = 0xffff ; while ( nLength > 0 ) { fcs = ( fcs >> 8 ) ^ crctab16 [ fcs ^ * pData ) & 0xff ]; nLength --; pData ++; } return ~ fcs ; } I have the fo //-->

How to convert uint8 Array to base64 Encoded String?

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I got a webSocket comunication, I recieve base64 encoded string, convert it to uint8 and work on it, but now I need to send back, I got the uint8 array, and need to convert it to base64 string, so I can send it. How can I make this convertion? 回答1: If your browser has TextDecoder then use that: var u8 = new Uint8Array([65, 66, 67, 68]); var decoder = new TextDecoder('utf8'); var b64encoded = btoa(decoder.decode(u8)); If you need to support browsers that do not have TextDecoder (currently just IE and Edge), then the best option is to use a

How to convert iTextPDF Document to Byte Array

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to convert iTextPDF Document file to byte[] after it's created in memory . I have already tested that I've no problem with creating PDF properly. The problem is how to convert it to byte array to store in DB. Here's my code: Document generatedDocument = reportService.generateRequestForm(scdUser, jsonObject, 0, null); reportService.generateRequestForm(scdUser, jsonObject, 0, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter pdfWriter = PdfWriter.getInstance(generatedDocument, baos); generatedDocument.open();

Convert cell array of cell arrays to matrix of matrices

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I can convert a cell array of matrices to matrix: >> C={[1,1]; [2,2]; [3,3]}; >> cell2mat(C) ans = 1 1 2 2 3 3 This is OK. But, I want to convert a cell array including other cell arrays to a matrix: >> C={{1,1}; {2,2}; {3,3}}; >> cell2mat(C) Error using cell2mat (line 53) Cannot support cell arrays containing cell arrays or objects. So, desired output is: >> mycell2mat({{1,1}; {2,2}; {3,3}}) ans = 1 1 2 2 3 3 How to do this? Edit: I want to do same thing for multidimensional ones also: >> mycell2mat({{1,1;1,1}; {2,2;2,2}; {3,3;3,3}}) ans(:,

Cannot implicitly convert type 'decimal?' to 'decimal'.

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: sdr is my sqldatareader and I want to check that the curPrice value which is of type decimal is null. inrec.curPrice = sdr.IsDBNull(7) ? (decimal?)null : sdr.GetDecimal(7); This is the error message I am getting: Cannot implicitly convert type 'decimal?' to 'decimal'. An explicit conversion exists (are you missing a cast?) Where am I going wrong, please someone tell me. 回答1: either convert curPrice to nullable, or use .Value property of nullable types. If curPrice is a property of a class then public decimal? curPrice { get; set; } 回答2:

How to convert uploaded images always into JPG format? [closed]

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have simply upload: $path = "uploads/"; $actual_image_name = time().$session_id.".".$ext; $tmp = $_FILES['photoimg']['tmp_name']; move_uploaded_file($tmp, $path.$actual_image_name); How can i add for this function imagejpeg? I would like always save image with JPG format. 回答1: Try this: <?php $path = "uploads/"; $img = $_FILES['photoimg']['tmp_name']; $dst = $path . $_FILES['photoimg']['name']; if (($img_info = getimagesize($img)) === FALSE) die("Image not found or not an image"); $width = $img_info[0]; $height = $img_info[1]; switch ($img

How to convert std::string to LPCSTR?

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I convert a std::string to LPCSTR ? Also, how can I convert a std::string to LPWSTR ? I am totally confused with these LPCSTR LPSTR LPWSTR and LPCWSTR . Are LPWSTR and LPCWSTR the same? 回答1: str.c_str() gives you a const char * , which is an LPCSTR (Long Pointer to Constant STRing) -- means that it's a pointer to a 0 terminated string of characters. W means wide string (composed of wchar_t instead of char ). 回答2: Call c_str() to get a const char * ( LPCSTR ) from a std::string . It's all in the name: LPSTR - (long) pointer to string