图像保存到指定路径,CString转char*

本文介绍了一种使用C++及OpenCV库保存图像的方法。通过获取当前时间并格式化为字符串,将其作为图像文件名的一部分,确保文件名的唯一性。接着通过构造保存文件对话框让用户选择保存路径及文件类型,最后利用OpenCV库函数cvSaveImage保存选定的图像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CString FilePathName;
    CString strTime;
    CTime tm;
    tm = CTime::GetCurrentTime();
    strTime = tm.Format("%Y%m%d%H%M%S");
    FilePathName = strTime + _T(".bmp");
    // 设置过滤器 
    TCHAR szFilter[] = _T("BMP Files (*.bmp)|*.bmp|JPG Files (*.jpg)|*.jpg|JPEG Files (*.jpeg)|*.jpeg|TIFF Files(.tif)|*.tif||");
    // 构造保存文件对话框 
    CFileDialog fileDlg(FALSE, _T(""), strTime, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this);

    // 显示保存文件对话框   
    if (IDOK == fileDlg.DoModal())
    {
        // 如果点击了文件对话框上的“保存”按钮,则将选择的文件路径显示到编辑框里   
        FilePathName = fileDlg.GetPathName();
        char* ttt;
        LPCTSTR p = FilePathName.GetBuffer(0);
        FilePathName.ReleaseBuffer();
        ttt = new char[FilePathName.GetLength() + 1];
        strcpy_s(ttt, FilePathName.GetLength() + 1, CT2CA(p));
        cvSaveImage(ttt, Cur_Frame);    

    }
/** * @struct RKLLMParam * @brief Defines the parameters for configuring an LLM instance. */ typedef struct { const char* model_path; /**< Path to the model file. */ int32_t max_context_len; /**< Maximum number of tokens in the context window. */ int32_t max_new_tokens; /**< Maximum number of new tokens to generate. */ int32_t top_k; /**< Top-K sampling parameter for token generation. */ float top_p; /**< Top-P (nucleus) sampling parameter. */ float temperature; /**< Sampling temperature, affecting the randomness of token selection. */ float repeat_penalty; /**< Penalty for repeating tokens in generation. */ float frequency_penalty; /**< Penalizes frequent tokens during generation. */ float presence_penalty; /**< Penalizes tokens based on their presence in the input. */ int32_t mirostat; /**< Mirostat sampling strategy flag (0 to disable). */ float mirostat_tau; /**< Tau parameter for Mirostat sampling. */ float mirostat_eta; /**< Eta parameter for Mirostat sampling. */ bool skip_special_token; /**< Whether to skip special tokens during generation. */ bool is_async; /**< Whether to run inference asynchronously. */ const char* img_start; /**< Starting position of an image in multimodal input. */ const char* img_end; /**< Ending position of an image in multimodal input. */ const char* img_content; /**< Pointer to the image content. */ RKLLMExtendParam extend_param; /**< Extend parameters. */ } RKLLMParam; /** * @brief Creates a default RKLLMParam structure with preset values. * @return A default RKLLMParam structure. */ RKLLMParam rkllm_createDefaultParam();换为node ffi代码
03-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值